diff --git a/code/ui/manager/scripts/generate-exports-file.ts b/code/ui/manager/scripts/generate-exports-file.ts index 7c3ae60e4203..2c38a0da6417 100644 --- a/code/ui/manager/scripts/generate-exports-file.ts +++ b/code/ui/manager/scripts/generate-exports-file.ts @@ -2,35 +2,39 @@ import fs from 'fs-extra'; import path from 'path'; import { dedent } from 'ts-dedent'; -import { exec } from '../../../../scripts/utils/exec'; +import { ESLint } from '../../../../scripts/node_modules/eslint'; +import { values } from '../src/globals/runtime'; const removeDefault = (input: string) => input !== 'default'; const location = path.join(__dirname, '..', 'src', 'globals', 'exports.ts'); const run = async () => { - const { values } = await import('../src/globals/runtime'); const data = Object.entries(values).reduce>((acc, [key, value]) => { acc[key] = Object.keys(value).filter(removeDefault); return acc; }, {}); console.log('Generating...'); - await fs.ensureFile(location); - await fs.writeFile( - location, - dedent` - // this file is generated by generate-exports-file.ts - // this is done to prevent runtime dependencies from making it's way into the build/start script of the manager - // the manager builder needs to know which dependencies are 'globalized' in the ui + const readyToWrite = fs.ensureFile(location); + const text = dedent` + // this file is generated by generate-exports-file.ts + // this is done to prevent runtime dependencies from making it's way into the build/start script of the manager + // the manager builder needs to know which dependencies are 'globalized' in the ui - export default ${JSON.stringify(data, null, 2)} as const;` - ); + export default ${JSON.stringify(data, null, 2)} as const;`; console.log('Linting...'); - await exec(`yarn lint:js:cmd --fix ${location}`, { - cwd: path.join(__dirname, '..', '..', '..'), + + const eslint = new ESLint({ + cwd: path.join(__dirname, '..'), + fix: true, }); + const output = await eslint.lintText(text, { filePath: location }); + + await readyToWrite; + await fs.writeFile(location, output[0].output); + console.log('Done!'); }; diff --git a/scripts/package.json b/scripts/package.json index 54bbc9c0c059..da33e97b95fb 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -113,6 +113,7 @@ "enzyme-adapter-react-16": "^1.15.5", "esbuild": "^0.14.48", "esbuild-plugin-alias": "^0.2.1", + "esbuild-register": "^3.4.1", "eslint": "^8.27.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-react": "^7.31.10", diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index 17aaf16ac295..7a15a2028129 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -18,10 +18,8 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { bundler: { entries = [], untypedEntries = [], platform, pre, post }, } = await fs.readJson(join(cwd, 'package.json')); - const tsnodePath = join(__dirname, '..', 'node_modules', '.bin', 'ts-node'); - if (pre) { - await exec(`${tsnodePath} ${pre}`, { cwd }); + await exec(`node -r ${__dirname}/../node_modules/esbuild-register/register.js ${pre}`, { cwd }); } const reset = hasFlag(flags, 'reset'); @@ -125,7 +123,11 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { ]); if (post) { - await exec(`${tsnodePath} ${post}`, { cwd }, { debug: true }); + await exec( + `node -r ${__dirname}/../node_modules/esbuild-register/register.js ${post}`, + { cwd }, + { debug: true } + ); } }; diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 46fac029c2e5..97ca4ec01c94 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -3270,6 +3270,7 @@ __metadata: enzyme-adapter-react-16: ^1.15.5 esbuild: ^0.14.48 esbuild-plugin-alias: ^0.2.1 + esbuild-register: ^3.4.1 eslint: ^8.27.0 eslint-plugin-import: ^2.26.0 eslint-plugin-react: ^7.31.10 @@ -7688,6 +7689,17 @@ __metadata: languageName: node linkType: hard +"esbuild-register@npm:^3.4.1": + version: 3.4.1 + resolution: "esbuild-register@npm:3.4.1" + dependencies: + debug: ^4.3.4 + peerDependencies: + esbuild: ">=0.12 <1" + checksum: 6364c96f83fc4720d907d6342605f5891986c2a30fbc0a249047195ea5b02c0f7e4e698aa262875b37088f44ca741331d35c026d2606778d114fe082d560957d + languageName: node + linkType: hard + "esbuild-sunos-64@npm:0.14.54": version: 0.14.54 resolution: "esbuild-sunos-64@npm:0.14.54"