Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of conflicting namespace exports (#2893)
* test: "export *" before named export * Prioritize local exports over external exports when resolving export all modules
- Loading branch information
1 parent
7d1bd82
commit f4b19ab
Showing
10 changed files
with
133 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
description: 'external `export *` must not interfere with internal exports', | ||
options: { | ||
output: { name: 'exposedInternals' }, | ||
external: ['external'] | ||
} | ||
}; |
19 changes: 19 additions & 0 deletions
19
test/form/samples/export-all-before-named/_expected/amd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
define(['exports', 'external'], function (exports, external) { 'use strict'; | ||
|
||
function internalFn(path) { | ||
return path[0] === '.'; | ||
} | ||
|
||
Object.keys(external).forEach(function (key) { | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return external[key]; | ||
} | ||
}); | ||
}); | ||
exports.internalFn = internalFn; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}); |
19 changes: 19 additions & 0 deletions
19
test/form/samples/export-all-before-named/_expected/cjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
var external = require('external'); | ||
|
||
function internalFn(path) { | ||
return path[0] === '.'; | ||
} | ||
|
||
Object.keys(external).forEach(function (key) { | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return external[key]; | ||
} | ||
}); | ||
}); | ||
exports.internalFn = internalFn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from 'external'; | ||
|
||
function internalFn(path) { | ||
return path[0] === '.'; | ||
} | ||
|
||
export { internalFn }; |
20 changes: 20 additions & 0 deletions
20
test/form/samples/export-all-before-named/_expected/iife.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var exposedInternals = (function (exports, external) { | ||
'use strict'; | ||
|
||
function internalFn(path) { | ||
return path[0] === '.'; | ||
} | ||
|
||
Object.keys(external).forEach(function (key) { | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return external[key]; | ||
} | ||
}); | ||
}); | ||
exports.internalFn = internalFn; | ||
|
||
return exports; | ||
|
||
}({}, external)); |
22 changes: 22 additions & 0 deletions
22
test/form/samples/export-all-before-named/_expected/system.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
System.register('exposedInternals', ['external'], function (exports) { | ||
'use strict'; | ||
var _starExcludes = { internalFn: 1, default: 1 }; | ||
return { | ||
setters: [function (module) { | ||
var _setter = {}; | ||
for (var _$p in module) { | ||
if (!_starExcludes[_$p]) _setter[_$p] = module[_$p]; | ||
} | ||
exports(_setter); | ||
}], | ||
execute: function () { | ||
|
||
exports('internalFn', internalFn); | ||
|
||
function internalFn(path) { | ||
return path[0] === '.'; | ||
} | ||
|
||
} | ||
}; | ||
}); |
23 changes: 23 additions & 0 deletions
23
test/form/samples/export-all-before-named/_expected/umd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'external'], factory) : | ||
(global = global || self, factory(global.exposedInternals = {}, global.external)); | ||
}(this, function (exports, external) { 'use strict'; | ||
|
||
function internalFn(path) { | ||
return path[0] === '.'; | ||
} | ||
|
||
Object.keys(external).forEach(function (key) { | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return external[key]; | ||
} | ||
}); | ||
}); | ||
exports.internalFn = internalFn; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function internalFn(path) { | ||
return path[0] === '.'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from 'external'; | ||
export * from './internal.js'; |