@esmx/core 3.0.0-rc.62 → 3.0.0-rc.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/core.mjs +2 -1
- package/dist/manifest-json.d.ts +0 -4
- package/dist/module-config.mjs +7 -1
- package/dist/module-config.test.mjs +24 -0
- package/dist/utils/import-map.d.ts +31 -2
- package/dist/utils/import-map.mjs +18 -6
- package/dist/utils/import-map.test.mjs +583 -314
- package/package.json +3 -3
- package/src/core.ts +2 -1
- package/src/manifest-json.ts +0 -4
- package/src/module-config.test.ts +31 -0
- package/src/module-config.ts +7 -1
- package/src/utils/import-map.test.ts +722 -342
- package/src/utils/import-map.ts +53 -9
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"build": "unbuild"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@esmx/import": "3.0.0-rc.
|
|
62
|
+
"@esmx/import": "3.0.0-rc.64",
|
|
63
63
|
"@types/serialize-javascript": "^5.0.4",
|
|
64
64
|
"es-module-lexer": "^1.7.0",
|
|
65
65
|
"find": "^0.3.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"unbuild": "3.6.0",
|
|
78
78
|
"vitest": "3.2.4"
|
|
79
79
|
},
|
|
80
|
-
"version": "3.0.0-rc.
|
|
80
|
+
"version": "3.0.0-rc.64",
|
|
81
81
|
"type": "module",
|
|
82
82
|
"private": false,
|
|
83
83
|
"exports": {
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"template",
|
|
101
101
|
"public"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "8c103750d1e623fa4fa23b6ed9149f39e4a9bd58"
|
|
104
104
|
}
|
package/src/core.ts
CHANGED
|
@@ -853,7 +853,7 @@ export class Esmx {
|
|
|
853
853
|
const manifests = await this.getManifestList(env);
|
|
854
854
|
let json: ImportMap = {};
|
|
855
855
|
switch (env) {
|
|
856
|
-
case 'client':
|
|
856
|
+
case 'client': {
|
|
857
857
|
json = getImportMap({
|
|
858
858
|
manifests,
|
|
859
859
|
getScope(name, scope) {
|
|
@@ -864,6 +864,7 @@ export class Esmx {
|
|
|
864
864
|
}
|
|
865
865
|
});
|
|
866
866
|
break;
|
|
867
|
+
}
|
|
867
868
|
case 'server':
|
|
868
869
|
json = getImportMap({
|
|
869
870
|
manifests,
|
package/src/manifest-json.ts
CHANGED
|
@@ -313,6 +313,37 @@ describe('Module Config Parser', () => {
|
|
|
313
313
|
expect(emptyScope.existing).toBe('existing-value');
|
|
314
314
|
expect(emptyScope.lodash).toBe('test-module/lodash');
|
|
315
315
|
});
|
|
316
|
+
|
|
317
|
+
it('should verify the specific scopes merging logic with imports', () => {
|
|
318
|
+
const config: ModuleConfig = {
|
|
319
|
+
imports: {
|
|
320
|
+
react: 'react',
|
|
321
|
+
vue: 'vue'
|
|
322
|
+
},
|
|
323
|
+
scopes: {
|
|
324
|
+
utils: {
|
|
325
|
+
lodash: 'lodash'
|
|
326
|
+
},
|
|
327
|
+
'': {
|
|
328
|
+
existing: 'existing-value'
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
const result = getEnvironments(config, 'client', 'test-module');
|
|
333
|
+
|
|
334
|
+
// 验证核心逻辑:imports 被合并到空字符串 scope 中
|
|
335
|
+
expect(result.scopes['']).toBeDefined();
|
|
336
|
+
expect(result.scopes[''].existing).toBe('existing-value'); // 保留现有内容
|
|
337
|
+
expect(result.scopes[''].react).toBe('react'); // 合并 imports
|
|
338
|
+
expect(result.scopes[''].vue).toBe('vue'); // 合并 imports
|
|
339
|
+
|
|
340
|
+
// 验证其他 scopes 不受影响
|
|
341
|
+
expect(result.scopes.utils.lodash).toBe('lodash');
|
|
342
|
+
|
|
343
|
+
// 验证 result.imports 也包含相同的 imports
|
|
344
|
+
expect(result.imports.react).toBe('react');
|
|
345
|
+
expect(result.imports.vue).toBe('vue');
|
|
346
|
+
});
|
|
316
347
|
});
|
|
317
348
|
|
|
318
349
|
describe('addPackageExportsToScopes', () => {
|
package/src/module-config.ts
CHANGED
|
@@ -145,7 +145,13 @@ export function getEnvironments(
|
|
|
145
145
|
): ParsedModuleConfigEnvironment {
|
|
146
146
|
const imports = getEnvironmentImports(env, config.imports);
|
|
147
147
|
const exports = getEnvironmentExports(config, env);
|
|
148
|
-
const scopes = getEnvironmentScopes(env,
|
|
148
|
+
const scopes = getEnvironmentScopes(env, {
|
|
149
|
+
...config.scopes,
|
|
150
|
+
'': {
|
|
151
|
+
...config.scopes?.[''],
|
|
152
|
+
...imports
|
|
153
|
+
}
|
|
154
|
+
});
|
|
149
155
|
addPackageExportsToScopes(exports, scopes, moduleName);
|
|
150
156
|
return {
|
|
151
157
|
imports,
|