Skip to content

Commit

Permalink
Change priorities so that chunk variable names take precedence over
Browse files Browse the repository at this point in the history
imported variable names
  • Loading branch information
lukastaegert committed Feb 14, 2019
1 parent a06fb8f commit 0cdb3eb
Show file tree
Hide file tree
Showing 53 changed files with 230 additions and 230 deletions.
6 changes: 3 additions & 3 deletions src/utils/deconflictChunk.ts
Expand Up @@ -36,14 +36,14 @@ export function deconflictChunk(
Object.assign(usedNames, forbiddenNames);
Object.assign(usedNames, formatGlobals);
addUsedGlobalNames(usedNames, modules);
deconflictTopLevelVariables(usedNames, modules);
DECONFLICT_IMPORTED_VARIABLES_BY_FORMAT[format](
usedNames,
imports,
dependencies,
interop,
preserveModules
);
deconflictTopLevelVariables(usedNames, modules);

for (const module of modules) {
module.scope.deconflict(forbiddenNames);
Expand Down Expand Up @@ -126,8 +126,8 @@ function deconflictTopLevelVariables(usedNames: NameCollection, modules: Module[
const variable = moduleVariables[name];
if (
variable.included &&
!// this will only happen for exports in some formats
(
// this will only happen for exports in some formats
!(
variable.renderBaseName ||
(variable instanceof ExportDefaultVariable && variable.referencesOriginal())
)
Expand Down
@@ -1,13 +1,13 @@
import { a as fn } from './generated-chunk.js';
import { a as fn$1 } from './generated-chunk.js';

function fn$1 () {
function fn () {
console.log('dep1 fn');
}

class Main1 {
constructor () {
fn$1();
fn();
fn$1();
}
}

Expand Down
10 changes: 5 additions & 5 deletions test/chunking-form/samples/basic-chunking/_expected/es/main2.js
@@ -1,18 +1,18 @@
import { a as fn } from './generated-chunk.js';
import { a as fn$2 } from './generated-chunk.js';

function fn$1 () {
function fn () {
console.log('lib1 fn');
}

function fn$2 () {
fn$1();
function fn$1 () {
fn();
console.log('dep3 fn');
}

class Main2 {
constructor () {
fn$1();
fn$2();
fn();
}
}

Expand Down
@@ -1,20 +1,20 @@
System.register(['./generated-chunk.js'], function (exports, module) {
'use strict';
var fn;
var fn$1;
return {
setters: [function (module) {
fn = module.a;
fn$1 = module.a;
}],
execute: function () {

function fn$1 () {
function fn () {
console.log('dep1 fn');
}

class Main1 {
constructor () {
fn$1();
fn();
fn$1();
}
} exports('default', Main1);

Expand Down
@@ -1,25 +1,25 @@
System.register(['./generated-chunk.js'], function (exports, module) {
'use strict';
var fn;
var fn$2;
return {
setters: [function (module) {
fn = module.a;
fn$2 = module.a;
}],
execute: function () {

function fn$1 () {
function fn () {
console.log('lib1 fn');
}

function fn$2 () {
fn$1();
function fn$1 () {
fn();
console.log('dep3 fn');
}

class Main2 {
constructor () {
fn$1();
fn$2();
fn();
}
} exports('default', Main2);

Expand Down
@@ -1,8 +1,8 @@
import { a as x } from './generated-chunk.js';
import { a as x$1 } from './generated-chunk3.js';
import { a as x$1 } from './generated-chunk.js';
import { a as x$2 } from './generated-chunk3.js';

var x$2 = x + 1;
var x = x$1 + 1;

var y = x$1 + 1;
var y = x$2 + 1;

export { x$2 as a, y as b };
export { x as a, y as b };
@@ -1,17 +1,17 @@
System.register(['./generated-chunk.js', './generated-chunk3.js'], function (exports, module) {
'use strict';
var x, x$1;
var x$1, x$2;
return {
setters: [function (module) {
x = module.a;
}, function (module) {
x$1 = module.a;
}, function (module) {
x$2 = module.a;
}],
execute: function () {

var x$2 = exports('a', x + 1);
var x = exports('a', x$1 + 1);

var y = exports('b', x$1 + 1);
var y = exports('b', x$2 + 1);

}
};
Expand Down
@@ -1,8 +1,8 @@
import {a as fn}from'./generated-chunk.js';function fn$1 () {
import {a as fn$1}from'./generated-chunk.js';function fn () {
console.log('dep1 fn');
}class Main1 {
constructor () {
fn$1();
fn();
fn$1();
}
}export default Main1;
@@ -1,12 +1,12 @@
import {a as fn$1}from'./generated-chunk.js';import {fn}from'external';function fn$2 () {
import {a as fn$3}from'./generated-chunk.js';import {fn as fn$2}from'external';function fn () {
console.log('lib1 fn');
fn();
}function fn$3 () {
fn$2();
}function fn$1 () {
fn();
console.log('dep3 fn');
}class Main2 {
constructor () {
fn$3();
fn$1();
fn$3();
}
}export default Main2;
@@ -1,8 +1,8 @@
System.register(['./generated-chunk.js'],function(exports,module){'use strict';var fn;return{setters:[function(module){fn=module.a;}],execute:function(){function fn$1 () {
System.register(['./generated-chunk.js'],function(exports,module){'use strict';var fn$1;return{setters:[function(module){fn$1=module.a;}],execute:function(){function fn () {
console.log('dep1 fn');
}class Main1 {
constructor () {
fn$1();
fn();
fn$1();
}
} exports('default', Main1);}}});
@@ -1,12 +1,12 @@
System.register(['./generated-chunk.js','external'],function(exports,module){'use strict';var fn$1,fn;return{setters:[function(module){fn$1=module.a;},function(module){fn=module.fn;}],execute:function(){function fn$2 () {
System.register(['./generated-chunk.js','external'],function(exports,module){'use strict';var fn$3,fn$2;return{setters:[function(module){fn$3=module.a;},function(module){fn$2=module.fn;}],execute:function(){function fn () {
console.log('lib1 fn');
fn();
}function fn$3 () {
fn$2();
}function fn$1 () {
fn();
console.log('dep3 fn');
}class Main2 {
constructor () {
fn$3();
fn$1();
fn$3();
}
} exports('default', Main2);}}});
@@ -1,13 +1,13 @@
import { a as fn } from './generated-chunk.js';
import { a as fn$1 } from './generated-chunk.js';

function fn$1 () {
function fn () {
console.log('dep1 fn');
}

class Main1 {
constructor () {
fn$1();
fn();
fn$1();
}
}

Expand Down
@@ -1,20 +1,20 @@
import { a as fn$1 } from './generated-chunk.js';
import { fn } from 'external';
import { a as fn$3 } from './generated-chunk.js';
import { fn as fn$2 } from 'external';

function fn$2 () {
function fn () {
console.log('lib1 fn');
fn();
fn$2();
}

function fn$3 () {
fn$2();
function fn$1 () {
fn();
console.log('dep3 fn');
}

class Main2 {
constructor () {
fn$3();
fn$1();
fn$3();
}
}

Expand Down
@@ -1,20 +1,20 @@
System.register(['./generated-chunk.js'], function (exports, module) {
'use strict';
var fn;
var fn$1;
return {
setters: [function (module) {
fn = module.a;
fn$1 = module.a;
}],
execute: function () {

function fn$1 () {
function fn () {
console.log('dep1 fn');
}

class Main1 {
constructor () {
fn$1();
fn();
fn$1();
}
} exports('default', Main1);

Expand Down
@@ -1,28 +1,28 @@
System.register(['./generated-chunk.js', 'external'], function (exports, module) {
'use strict';
var fn$1, fn;
var fn$3, fn$2;
return {
setters: [function (module) {
fn$1 = module.a;
fn$3 = module.a;
}, function (module) {
fn = module.fn;
fn$2 = module.fn;
}],
execute: function () {

function fn$2 () {
function fn () {
console.log('lib1 fn');
fn();
fn$2();
}

function fn$3 () {
fn$2();
function fn$1 () {
fn();
console.log('dep3 fn');
}

class Main2 {
constructor () {
fn$3();
fn$1();
fn$3();
}
} exports('default', Main2);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0cdb3eb

Please sign in to comment.