Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deploy-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
}
);
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export class TypeErasureCodemod implements Codemod<File, TypeErasureCodemodOptio
],
ast: true,
configFile: false,
// Skip browserslist config resolution. Without this, Babel's
// partial-config pipeline calls into @babel/helper-compilation-targets,
// which requires browserslist + baseline-browser-mapping (~170KB
// of code we never use since we don't pass any browser targets).
browserslistConfigFile: false,
});

return {
Expand Down
13 changes: 11 additions & 2 deletions src/infrastructure/application/cli/io/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ import isUnicodeSupported from 'is-unicode-supported';
import {render as renderMarkdown} from '@croct/md-lite/rendering.js';
import terminalLink from 'terminal-link';
import {unescape as unescapeMarkdown} from '@croct/md-lite/parsing.js';
import {strip} from 'node-emoji';
import type {Semantics} from '@/application/cli/io/output';

// Strips both unicode pictographs and `:shortcode:` markers from a string.
// Replaces node-emoji's strip(), which pulls a 275KB emoji dataset for the
// same effect when the terminal can't render unicode.
const EMOJI_PICTOGRAPH = /\p{Extended_Pictographic}(️|‍\p{Extended_Pictographic})*/gu;
const EMOJI_SHORTCODE = /:[\w+-]+:/g;

function stripEmoji(value: string): string {
return value.replace(EMOJI_PICTOGRAPH, '').replace(EMOJI_SHORTCODE, '');
}

const unicodeSupport = isUnicodeSupported();

export const colors: Record<Semantics, ForegroundColorName> = {
Expand Down Expand Up @@ -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) {
Expand Down
31 changes: 31 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -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 ({
Expand Down
Loading