Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support external star exports on namespace objects (#3474)
* feat: support external star exports on namespace objects * fixup test description, form test * fixup form tests * fixup Object.create assignment, __PURE__ tweaks * remove invalid test changes * Add pure annotations again, small refactor * Simplify namespace handling logic and extend tests * Improve coverage Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
- Loading branch information
1 parent
722bc25
commit 74cec2e
Showing
31 changed files
with
269 additions
and
71 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
define(['external'],function(x){'use strict';x=x&&Object.prototype.hasOwnProperty.call(x,'default')?x['default']:x;var self=/*#__PURE__*/Object.freeze({[Symbol.toStringTag]:'Module',__proto__:null,get default(){return foo}});console.log(self); | ||
define(['external'],function(x){'use strict';x=x&&Object.prototype.hasOwnProperty.call(x,'default')?x['default']:x;var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); | ||
function foo () { | ||
console.log( x ); | ||
} | ||
// trailing comment | ||
return foo;}); | ||
return foo;}); |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
var foo=(function(x){'use strict';x=x&&Object.prototype.hasOwnProperty.call(x,'default')?x['default']:x;var self=/*#__PURE__*/Object.freeze({[Symbol.toStringTag]:'Module',__proto__:null,get default(){return foo}});console.log(self); | ||
var foo=(function(x){'use strict';x=x&&Object.prototype.hasOwnProperty.call(x,'default')?x['default']:x;var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); | ||
function foo () { | ||
console.log( x ); | ||
} | ||
// trailing comment | ||
return foo;}(x)); | ||
return foo;}(x)); |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f(require('external')):typeof define==='function'&&define.amd?define(['external'],f):(g=g||self,g.foo=f(g.x));}(this,(function(x){'use strict';x=x&&Object.prototype.hasOwnProperty.call(x,'default')?x['default']:x;var self=/*#__PURE__*/Object.freeze({[Symbol.toStringTag]:'Module',__proto__:null,get default(){return foo}});console.log(self); | ||
(function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f(require('external')):typeof define==='function'&&define.amd?define(['external'],f):(g=g||self,g.foo=f(g.x));}(this,(function(x){'use strict';x=x&&Object.prototype.hasOwnProperty.call(x,'default')?x['default']:x;var self=/*#__PURE__*/Object.freeze({__proto__:null,[Symbol.toStringTag]:'Module',get default(){return foo}});console.log(self); | ||
function foo () { | ||
console.log( x ); | ||
} | ||
// trailing comment | ||
return foo;}))); | ||
return foo;}))); |
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
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
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
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,24 @@ | ||
module.exports = { | ||
description: 'supports namespaces with external star reexports', | ||
options: { | ||
external: ['external1', 'external2'], | ||
plugins: { | ||
transform(code, id) { | ||
if (id.endsWith('override.js')) { | ||
return { | ||
code, | ||
syntheticNamedExports: true | ||
}; | ||
} | ||
return null; | ||
} | ||
}, | ||
output: { | ||
globals: { | ||
external1: 'external1', | ||
external2: 'external2' | ||
}, | ||
name: 'bundle' | ||
} | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
test/form/samples/ns-external-star-reexport/_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,21 @@ | ||
define(['exports', 'external1', 'external2'], function (exports, external1, external2) { 'use strict'; | ||
|
||
var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1)); | ||
|
||
const extra = 'extra'; | ||
|
||
const override = 'override'; | ||
var reexportExternalsWithOverride = { synthetic: 'synthetic' }; | ||
|
||
var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1, external2, { | ||
override: override, | ||
'default': reexportExternalsWithOverride, | ||
extra: extra | ||
}, reexportExternalsWithOverride)); | ||
|
||
exports.external = reexportExternal; | ||
exports.externalOverride = reexportExternalsWithOverride$1; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}); |
22 changes: 22 additions & 0 deletions
22
test/form/samples/ns-external-star-reexport/_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,22 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
var external1 = require('external1'); | ||
var external2 = require('external2'); | ||
|
||
var reexportExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1)); | ||
|
||
const extra = 'extra'; | ||
|
||
const override = 'override'; | ||
var reexportExternalsWithOverride = { synthetic: 'synthetic' }; | ||
|
||
var reexportExternalsWithOverride$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), external1, external2, { | ||
override: override, | ||
'default': reexportExternalsWithOverride, | ||
extra: extra | ||
}, reexportExternalsWithOverride)); | ||
|
||
exports.external = reexportExternal; | ||
exports.externalOverride = reexportExternalsWithOverride$1; |
Oops, something went wrong.
Is there a way to avoid this
Object.assign
since it doesn't work in IE 11?