Skip to content

Commit f58ab58

Browse files
authored
perf: optimize module resolution of compiled packages (#6274)
1 parent bab9210 commit f58ab58

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

packages/core/prebundle.config.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default {
5353
name: 'launch-editor-middleware',
5454
ignoreDts: true,
5555
externals: {
56-
picocolors: '../picocolors',
56+
picocolors: '../picocolors/index.js',
5757
},
5858
},
5959
{
@@ -134,7 +134,7 @@ export default {
134134
name: 'postcss',
135135
copyDts: true,
136136
externals: {
137-
picocolors: '../picocolors',
137+
picocolors: '../picocolors/index.js',
138138
},
139139
afterBundle(task) {
140140
// source-map-js type does not exist, use a stub instead
@@ -160,22 +160,22 @@ export type SourceMapGenerator = unknown;
160160
name: 'css-loader',
161161
ignoreDts: true,
162162
externals: {
163-
postcss: '../postcss',
163+
postcss: '../postcss/index.js',
164164
},
165165
},
166166
{
167167
name: 'postcss-loader',
168168
externals: {
169169
jiti: 'jiti',
170-
postcss: '../postcss',
170+
postcss: '../postcss/index.js',
171171
},
172172
ignoreDts: true,
173173
},
174174
{
175175
name: '@jridgewell/remapping',
176176
ignoreDts: true,
177177
externals: {
178-
'@jridgewell/trace-mapping': '../trace-mapping',
178+
'@jridgewell/trace-mapping': '../trace-mapping/index.js',
179179
},
180180
},
181181
],
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
// @ts-check
2-
import { writeFileSync } from 'node:fs';
3-
import { join } from 'node:path';
4-
5-
// The package size of `schema-utils` is large, and validate has a performance overhead of tens of ms.
6-
// So we skip the validation and let TypeScript to ensure type safety.
7-
const writeEmptySchemaUtils = (task) => {
8-
const schemaUtilsPath = join(task.distPath, 'schema-utils.js');
9-
writeFileSync(schemaUtilsPath, 'module.exports.validate = () => {};');
10-
};
11-
122
/** @type {import('prebundle').Config} */
133
export default {
144
prettier: true,
@@ -18,9 +8,7 @@ export default {
188
ignoreDts: true,
199
externals: {
2010
'@babel/core': '@babel/core',
21-
'schema-utils': './schema-utils',
2211
},
23-
afterBundle: writeEmptySchemaUtils,
2412
},
2513
],
2614
};

0 commit comments

Comments
 (0)