Skip to content

Instantly share code, notes, and snippets.

@manzt
Created October 29, 2020 15:04
Show Gist options
  • Save manzt/e38d758c868d6a1a1237f433701f63f1 to your computer and use it in GitHub Desktop.
Save manzt/e38d758c868d6a1a1237f433701f63f1 to your computer and use it in GitHub Desktop.
esbuild code-splitting
import { log } from './shared';
export default (a: number, b: number): number => {
log();
return a + b;
}
export { default as add } from './add';
export { default as subtract } from './subtract';
{
"name": "esbuild-spltting-issue",
"version": "1.0.0",
"main": "dist/index.js",
"type": "module",
"exports": {
".": {
"import": "./dist/index.js"
},
"./add": {
"import": "./dist/add.js"
},
"./subtract": {
"import": "./dist/subtract.js"
}
},
"scripts": {
"build": "esbuild --bundle --splitting --format=esm --outdir=dist index.ts add.ts subtract.ts"
},
"dependencies": {
"esbuild": "^0.8.0"
}
}
export const log = (): void => console.log('I am shared code!');
import { log } from './shared';
export default (a: number, b: number): number => {
log();
return a - b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment