I want to migrate my Project from JS to TS and I'm using the ts-migrate-plugin from Airbnb. https://github.com/airbnb/ts-migrate/tree/master/packages/ts-migrate-plugins
But I got the error:
fs and perf_hooks dependencies are not found.
After searching on StackOverflow I found a solution for fs
// webpack.config.js
config.node = {
fs: 'empty',
};
module.exports = config;
My Question is why perf_hooks are not beeing found, although perf_hooks are included in nodejs? Something like:
// webpack.config.js
config.node = {
fs: 'empty',
perf_hooks: 'empty',
};
module.exports = config;
Does not fix the perf_hooks error:
This dependency was not found:
* perf_hooks in ./design/1/js/app.ts, ./node_modules/ts-migrate-server/build/src/utils/PerfTimer.js.
More details:
// app.ts
import path from 'path';
// eslint-disable-next-line import/no-extraneous-dependencies
import { tsIgnorePlugin } from 'ts-migrate-plugins';
// eslint-disable-next-line import/no-extraneous-dependencies
import { migrate, MigrateConfig } from 'ts-migrate-server';
// get input files folder
const inputDir = path.resolve(__dirname, 'input');
// create new migration config and add ts-ignore plugin with empty options
const config = new MigrateConfig().addPlugin(tsIgnorePlugin, {});
// run migration
migrate({ rootDir: inputDir, config }).then(exitCode => {
process.exit(exitCode);
});