Skip to content

Commit 18df9a6

Browse files
sastanlukastaegert
andauthored
WIP: test case for import namespace when only rendering systemjs (#3731)
* test case for import namespace when only rendering systemjs * Deconflict external namespace variables for SystemJS Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
1 parent f0f8c47 commit 18df9a6

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

src/Chunk.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -980,20 +980,20 @@ export default class Chunk {
980980
}
981981

982982
private getDependenciesToBeDeconflicted(
983-
addDependencies: boolean,
984-
addNonNamespaces: boolean,
985-
interop: GetInterop,
986-
addDependenciesWithoutBindings: boolean
983+
addNonNamespacesAndInteropHelpers: boolean,
984+
addInternalDependencies: boolean,
985+
addDependenciesWithoutBindings: boolean,
986+
interop: GetInterop
987987
): DependenciesToBeDeconflicted {
988988
const dependencies = new Set<Chunk | ExternalModule>();
989989
const deconflictedDefault = new Set<ExternalModule>();
990990
const deconflictedNamespace = new Set<ExternalModule>();
991-
if (addDependencies) {
992-
for (const variable of [...this.exportNamesByVariable.keys(), ...this.imports]) {
993-
if (addNonNamespaces || variable.isNamespace) {
994-
const module = variable.module!;
995-
if (module instanceof ExternalModule) {
996-
dependencies.add(module);
991+
for (const variable of [...this.exportNamesByVariable.keys(), ...this.imports]) {
992+
if (addNonNamespacesAndInteropHelpers || variable.isNamespace) {
993+
const module = variable.module!;
994+
if (module instanceof ExternalModule) {
995+
dependencies.add(module);
996+
if (addNonNamespacesAndInteropHelpers) {
997997
if (variable.name === 'default') {
998998
if (defaultInteropHelpersByInteropType[String(interop(module.id))]) {
999999
deconflictedDefault.add(module);
@@ -1003,11 +1003,11 @@ export default class Chunk {
10031003
deconflictedNamespace.add(module);
10041004
}
10051005
}
1006-
} else {
1007-
const chunk = this.chunkByModule.get(module)!;
1008-
if (chunk !== this) {
1009-
dependencies.add(chunk);
1010-
}
1006+
}
1007+
} else if (addInternalDependencies) {
1008+
const chunk = this.chunkByModule.get(module)!;
1009+
if (chunk !== this) {
1010+
dependencies.add(chunk);
10111011
}
10121012
}
10131013
}
@@ -1238,10 +1238,10 @@ export default class Chunk {
12381238
deconflictChunk(
12391239
this.orderedModules,
12401240
this.getDependenciesToBeDeconflicted(
1241-
format !== 'system',
12421241
format !== 'es' && format !== 'system',
1243-
interop,
1244-
format === 'amd' || format === 'umd' || format === 'iife'
1242+
format !== 'system',
1243+
format === 'amd' || format === 'umd' || format === 'iife',
1244+
interop
12451245
),
12461246
this.imports,
12471247
usedNames,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
description: 'imports namespace (systemjs only)',
3+
options: {
4+
external: ['dependency'],
5+
output: {
6+
format: 'system'
7+
}
8+
}
9+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
System.register(['dependency'], function () {
2+
'use strict';
3+
var dependency;
4+
return {
5+
setters: [function (module) {
6+
dependency = module;
7+
}],
8+
execute: function () {
9+
10+
console.log(dependency);
11+
12+
}
13+
};
14+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import * as dependency from 'dependency';
2+
console.log(dependency);

0 commit comments

Comments
 (0)