Skip to content

Commit

Permalink
Simplify tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 30, 2018
1 parent 366a9fe commit af1c537
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
18 changes: 3 additions & 15 deletions src/Chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ export default class Chunk {
}
}

// TODO Lukas can this be simplified to directly set the exports?
// TODO Lukas dynamic imports -> always named export mode!
// TODO Lukas multiple entry points -> always generate facade for more than one
// TODO Lukas handle circularly connected entries
Expand All @@ -253,21 +252,17 @@ export default class Chunk {
module,
map: this.getExportVariableMapForModule(module)
}));
const exposedVariables: Set<Variable> = new Set();
const variableByExportName: Map<string, Variable> = new Map();
for (const { map } of exportVariableMaps) {
for (const exposedVariable of Array.from(map.keys())) {
exposedVariables.add(exposedVariable);
this.exports.set(exposedVariable, map.get(exposedVariable).module);
for (const exportName of map.get(exposedVariable).exportNames) {
variableByExportName.set(exportName, exposedVariable);
}
}
}
for (const exposedVariable of Array.from(this.exports.keys())) {
exposedVariables.add(exposedVariable);
}
checkNextEntryModule: for (const { map, module } of exportVariableMaps) {
for (const exposedVariable of Array.from(exposedVariables)) {
for (const exposedVariable of Array.from(this.exports.keys())) {
if (
!map.has(exposedVariable) ||
map
Expand All @@ -280,9 +275,8 @@ export default class Chunk {
continue checkNextEntryModule;
}
}
for (const [variable, { exportNames, module }] of Array.from(map)) {
for (const [variable, { exportNames }] of Array.from(map)) {
for (const exportName of exportNames) {
this.exports.set(variable, module);
this.exportNames[exportName] = variable;
}
}
Expand Down Expand Up @@ -368,12 +362,6 @@ export default class Chunk {
}

if (module.chunk !== this) {
// we follow reexports if they are not entry points in the hope
// that we can get an entry point reexport to reduce the chance of
// tainting an entryModule chunk by exposing other unnecessary exports
// TODO Lukas this should also stop for dynamic entries, test this
if (module.isEntryPoint && !module.chunk.isEmpty)
return { variable: module.traceExport(name), module };
return module.chunk.traceExport(name, module);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import hsl2hsv from './hsl2hsv.js';

export { default as b } from './hsl2hsv.js';

var hsl2hsv$1 = 'asdf';

console.log(hsl2hsv$1);
Expand All @@ -8,4 +10,4 @@ var lib = /*#__PURE__*/Object.freeze({
hsl2hsv: hsl2hsv
});

export { hsl2hsv as a, lib as b };
export { lib as a };
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { a as hsl2hsv } from './index-6a71658c.js';
export { b as hsl2hsv } from './index-6a71658c.js';
import './hsl2hsv.js';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { p } from './hsl2hsv.js';
import { a as hsl2hsv, b as lib } from './index-6a71658c.js';
import { a as lib } from './index-6a71658c.js';

console.log(p);
var main = new Map(Object.entries(lib));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ System.register(['./hsl2hsv.js'], function (exports, module) {
return {
setters: [function (module) {
hsl2hsv = module.default;
exports('b', module.default);
}],
execute: function () {

Expand All @@ -14,7 +15,7 @@ System.register(['./hsl2hsv.js'], function (exports, module) {
var lib = /*#__PURE__*/Object.freeze({
hsl2hsv: hsl2hsv
});
exports('b', lib);
exports('a', lib);

}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
System.register(['./index-8b381a8d.js', './hsl2hsv.js'], function (exports, module) {
System.register(['./index-51f0f10d.js', './hsl2hsv.js'], function (exports, module) {
'use strict';
return {
setters: [function (module) {
exports('hsl2hsv', module.a);
exports('hsl2hsv', module.b);
}, function () {}],
execute: function () {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
System.register(['./hsl2hsv.js', './index-8b381a8d.js'], function (exports, module) {
System.register(['./hsl2hsv.js', './index-51f0f10d.js'], function (exports, module) {
'use strict';
var p, hsl2hsv, lib;
var hsl2hsv, p, lib;
return {
setters: [function (module) {
hsl2hsv = module.default;
p = module.p;
}, function (module) {
hsl2hsv = module.a;
lib = module.b;
lib = module.a;
}],
execute: function () {

Expand Down

0 comments on commit af1c537

Please sign in to comment.