Skip to content

Commit befdf2d

Browse files
committed
Enable code splitting
1 parent fe758df commit befdf2d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"bugs": {
77
"url": "https://github.com/MetaMask/utils/issues"
88
},
9+
"sideEffects": false,
910
"repository": {
1011
"type": "git",
1112
"url": "https://github.com/MetaMask/utils.git"
@@ -19,8 +20,6 @@
1920
},
2021
"./package.json": "./package.json"
2122
},
22-
"main": "./dist/index.js",
23-
"module": "./dist/index.mjs",
2423
"types": "./dist/types/index.d.ts",
2524
"files": [
2625
"dist"

tsconfig.build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"./src/**/__tests__/**/*",
1919
"./src/**/__snapshots__/**/*",
2020
"./src/**/*.test.ts",
21+
"./src/**/*.test-d.ts",
2122
"./src/**/*.test.*.ts"
2223
]
2324
}

tsup.config.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ import { defineConfig } from 'tsup';
22

33
export default defineConfig({
44
// The entry to bundle.
5-
entry: ['src/index.ts'],
5+
entry: [
6+
'src/**/*.ts',
7+
'!src/**/__fixtures__/**/*',
8+
'!src/**/__mocks__/**/*',
9+
'!src/**/__test__/**/*',
10+
'!src/**/__tests__/**/*',
11+
'!src/**/__snapshots__/**/*',
12+
'!src/**/*.test.ts',
13+
'!src/**/*.test-d.ts',
14+
'!src/**/*.test.*.ts',
15+
],
616

717
// The output formats. We want to generate both CommonJS and ESM bundles.
818
// https://tsup.egoist.dev/#bundle-formats
@@ -18,9 +28,13 @@ export default defineConfig({
1828
// Enables shimming of `__dirname` and `import.meta.url`, so that they work
1929
// in both CommonJS and ESM.
2030
// https://tsup.egoist.dev/#inject-cjs-and-esm-shims
21-
shims: true,
31+
shims: false,
2232

2333
// Hide unnecessary logs from the console. Warnings and errors will still be
2434
// shown.
2535
silent: true,
36+
37+
// Split the output into chunks. This is useful for tree-shaking.
38+
// https://tsup.egoist.dev/#code-splitting
39+
splitting: true,
2640
});

0 commit comments

Comments
 (0)