Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: test case for import namespace when only rendering systemjs #3731

Merged
merged 2 commits into from
Aug 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/Chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,20 +980,20 @@ export default class Chunk {
}

private getDependenciesToBeDeconflicted(
addDependencies: boolean,
addNonNamespaces: boolean,
interop: GetInterop,
addDependenciesWithoutBindings: boolean
addNonNamespacesAndInteropHelpers: boolean,
addInternalDependencies: boolean,
addDependenciesWithoutBindings: boolean,
interop: GetInterop
): DependenciesToBeDeconflicted {
const dependencies = new Set<Chunk | ExternalModule>();
const deconflictedDefault = new Set<ExternalModule>();
const deconflictedNamespace = new Set<ExternalModule>();
if (addDependencies) {
for (const variable of [...this.exportNamesByVariable.keys(), ...this.imports]) {
if (addNonNamespaces || variable.isNamespace) {
const module = variable.module!;
if (module instanceof ExternalModule) {
dependencies.add(module);
for (const variable of [...this.exportNamesByVariable.keys(), ...this.imports]) {
if (addNonNamespacesAndInteropHelpers || variable.isNamespace) {
const module = variable.module!;
if (module instanceof ExternalModule) {
dependencies.add(module);
if (addNonNamespacesAndInteropHelpers) {
if (variable.name === 'default') {
if (defaultInteropHelpersByInteropType[String(interop(module.id))]) {
deconflictedDefault.add(module);
Expand All @@ -1003,11 +1003,11 @@ export default class Chunk {
deconflictedNamespace.add(module);
}
}
} else {
const chunk = this.chunkByModule.get(module)!;
if (chunk !== this) {
dependencies.add(chunk);
}
}
} else if (addInternalDependencies) {
const chunk = this.chunkByModule.get(module)!;
if (chunk !== this) {
dependencies.add(chunk);
}
}
}
Expand Down Expand Up @@ -1238,10 +1238,10 @@ export default class Chunk {
deconflictChunk(
this.orderedModules,
this.getDependenciesToBeDeconflicted(
format !== 'system',
format !== 'es' && format !== 'system',
interop,
format === 'amd' || format === 'umd' || format === 'iife'
format !== 'system',
format === 'amd' || format === 'umd' || format === 'iife',
interop
),
this.imports,
usedNames,
Expand Down
9 changes: 9 additions & 0 deletions test/form/samples/import-namespace-systemjs/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
description: 'imports namespace (systemjs only)',
options: {
external: ['dependency'],
output: {
format: 'system'
}
}
};
14 changes: 14 additions & 0 deletions test/form/samples/import-namespace-systemjs/_expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
System.register(['dependency'], function () {
'use strict';
var dependency;
return {
setters: [function (module) {
dependency = module;
}],
execute: function () {

console.log(dependency);

}
};
});
2 changes: 2 additions & 0 deletions test/form/samples/import-namespace-systemjs/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as dependency from 'dependency';
console.log(dependency);