diff --git a/.github/workflows/deploy-preview.yaml b/.github/workflows/deploy-preview.yaml index df3c990..ee1a2fb 100644 --- a/.github/workflows/deploy-preview.yaml +++ b/.github/workflows/deploy-preview.yaml @@ -39,6 +39,7 @@ jobs: - name: Prepare release run: |- cp package.json LICENSE README.md build/ + npm --prefix build pkg delete dependencies cd build - name: Publish preview diff --git a/.github/workflows/deploy-release.yaml b/.github/workflows/deploy-release.yaml index 5b3781e..ecaaf77 100644 --- a/.github/workflows/deploy-release.yaml +++ b/.github/workflows/deploy-release.yaml @@ -13,6 +13,7 @@ jobs: npm run graphql-codegen && sed -i -e "s~\"version\": \"0.0.0-dev\"~\"version\": \"${GITHUB_REF##*/}\"~" package.json prepare-script: >- - cp package.json LICENSE README.md build/ + cp package.json LICENSE README.md build/ && + npm --prefix build pkg delete dependencies secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/eslint.config.mjs b/eslint.config.mjs index ac6d577..2ea6c51 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -29,6 +29,9 @@ export default defineConfig( files: ['tsup.config.ts'], rules: { 'import/no-default-export': 'off', + 'import-x/no-default-export': 'off', + 'object-shorthand': 'off', + 'func-names': 'off', }, } ); \ No newline at end of file diff --git a/package.json b/package.json index 4653402..8a3f4a0 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,6 @@ "is-unicode-supported": "^2.1.0", "jsep": "^1.4.0", "minimatch": "^10.0.3", - "node-emoji": "^2.2.0", "open": "^10.2.0", "prompts": "^2.4.2", "recast": "^0.23.11", diff --git a/src/application/project/code/transformation/javascript/typeErasureCodemod.ts b/src/application/project/code/transformation/javascript/typeErasureCodemod.ts index 9101657..aebbcaa 100644 --- a/src/application/project/code/transformation/javascript/typeErasureCodemod.ts +++ b/src/application/project/code/transformation/javascript/typeErasureCodemod.ts @@ -93,6 +93,11 @@ export class TypeErasureCodemod implements Codemod = { @@ -43,7 +52,7 @@ export function format(message: string, options: FormatingOptions = {}): string let result = options.basic === true ? message : render(message); if (!unicodeSupport) { - result = strip(result); + result = stripEmoji(result); } if (options.text !== undefined) { diff --git a/tsup.config.ts b/tsup.config.ts index 728fead..56a13f1 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,16 +1,47 @@ +import type {Plugin} from 'esbuild'; import {defineConfig} from 'tsup'; +// Modules whose code paths are unreachable in our usage. Resolving them to +// an empty module saves ~700KB: +// - `@babel/preset-typescript`: loaded by @babel/core for `.cts` configs +// (we always pass configFile: false). +// - `esprima`: recast's tokenizer fallback when AST has no `tokens`; our +// `@babel/parser`-based recast parser always provides them. +// - `browserslist`: required by @babel/helper-compilation-targets; never +// invoked since we set `browserslistConfigFile: false`. +const namespace = 'stub-unreachable-modules'; +const pattern = /^@babel\/preset-typescript(\/.*)?$|^esprima$|^browserslist$/; + +const stubUnreachableModules: Plugin = { + name: namespace, + setup(build) { + build.onResolve( + {filter: pattern}, + args => ({path: args.path, namespace}), + ); + build.onLoad( + {filter: /.*/, namespace}, + () => ({contents: 'module.exports = {};', loader: 'js'}), + ); + }, +}; + export default defineConfig({ entry: { index: 'src/program.ts', }, format: 'esm', target: 'esnext', + platform: 'node', clean: true, sourcemap: false, minify: true, outDir: 'build', treeshake: true, + // Bundle every dependency into the output so consumers don't get + // anything installed transitively (avoids version conflicts in host projects). + noExternal: [/.*/], + esbuildPlugins: [stubUnreachableModules], banner: ({format}) => { if (format === 'esm') { return ({