Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "default" reexport issues in non ESM/System formats (#3084)
* Restructure reexport tests and add failing tests * Properly export default as efault * Use correct variable name when reexporting default + names * Replace some side-effectful "some" with proper loops * Use template strings to handle compact mode * Improve coverage * Retrigger CI * Improve coverage and replace some forEach loops
- Loading branch information
1 parent
cc5fd63
commit e2fa18d
Showing
82 changed files
with
580 additions
and
162 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
description: 'properly associate or shadow variables in and around functions', | ||
options: { | ||
external: ['external1', 'external2'], | ||
output: { | ||
globals: { external1: 'external1', external2: 'external2' }, | ||
name: 'iife' | ||
} | ||
} | ||
}; |
15 changes: 15 additions & 0 deletions
15
test/form/samples/namespace-import-reexport-2/_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,15 @@ | ||
define(['exports', 'external1', 'external2'], function (exports, external1, external2) { 'use strict'; | ||
|
||
|
||
|
||
Object.defineProperty(exports, 'x', { | ||
enumerable: true, | ||
get: function () { | ||
return external1.x; | ||
} | ||
}); | ||
exports.ext = external2; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}); |
16 changes: 16 additions & 0 deletions
16
test/form/samples/namespace-import-reexport-2/_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,16 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
var external1 = require('external1'); | ||
var external2 = require('external2'); | ||
|
||
|
||
|
||
Object.defineProperty(exports, 'x', { | ||
enumerable: true, | ||
get: function () { | ||
return external1.x; | ||
} | ||
}); | ||
exports.ext = external2; |
3 changes: 3 additions & 0 deletions
3
test/form/samples/namespace-import-reexport-2/_expected/es.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,3 @@ | ||
export { x } from 'external1'; | ||
import * as external2 from 'external2'; | ||
export { external2 as ext }; |
16 changes: 16 additions & 0 deletions
16
test/form/samples/namespace-import-reexport-2/_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,16 @@ | ||
var iife = (function (exports, external1, external2) { | ||
'use strict'; | ||
|
||
|
||
|
||
Object.defineProperty(exports, 'x', { | ||
enumerable: true, | ||
get: function () { | ||
return external1.x; | ||
} | ||
}); | ||
exports.ext = external2; | ||
|
||
return exports; | ||
|
||
}({}, external1, external2)); |
15 changes: 15 additions & 0 deletions
15
test/form/samples/namespace-import-reexport-2/_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,15 @@ | ||
System.register('iife', ['external1', 'external2'], function (exports) { | ||
'use strict'; | ||
return { | ||
setters: [function (module) { | ||
exports('x', module.x); | ||
}, function (module) { | ||
exports('ext', module); | ||
}], | ||
execute: function () { | ||
|
||
|
||
|
||
} | ||
}; | ||
}); |
17 changes: 17 additions & 0 deletions
17
test/form/samples/namespace-import-reexport-2/_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,17 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('external1'), require('external2')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'external1', 'external2'], factory) : | ||
(global = global || self, factory(global.iife = {}, global.external1, global.external2)); | ||
}(this, function (exports, external1, external2) { 'use strict'; | ||
|
||
Object.defineProperty(exports, 'x', { | ||
enumerable: true, | ||
get: function () { | ||
return external1.x; | ||
} | ||
}); | ||
exports.ext = external2; | ||
|
||
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 { x } from 'external1'; | ||
import * as ext from 'external2'; | ||
export { ext }; |
11 changes: 0 additions & 11 deletions
11
test/form/samples/re-export-default-external-as-default/_config.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
test/form/samples/reexport-external-default-and-name/_config.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,12 @@ | ||
module.exports = { | ||
description: | ||
'reexports a an external default as a name and imports another name from that dependency', | ||
expectedWarnings: ['MIXED_EXPORTS'], | ||
options: { | ||
external: ['external'], | ||
output: { | ||
globals: { external: 'external' }, | ||
name: 'bundle' | ||
} | ||
} | ||
}; |
12 changes: 12 additions & 0 deletions
12
test/form/samples/reexport-external-default-and-name/_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,12 @@ | ||
define(['exports', 'external'], function (exports, external) { 'use strict'; | ||
|
||
external = external && external.hasOwnProperty('default') ? external['default'] : external; | ||
|
||
const value = 42; | ||
|
||
exports.default = external; | ||
exports.value = value; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
}); |
12 changes: 12 additions & 0 deletions
12
test/form/samples/reexport-external-default-and-name/_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,12 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
|
||
var external = _interopDefault(require('external')); | ||
|
||
const value = 42; | ||
|
||
exports.default = external; | ||
exports.value = value; |
5 changes: 5 additions & 0 deletions
5
test/form/samples/reexport-external-default-and-name/_expected/es.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,5 @@ | ||
export { default } from 'external'; | ||
|
||
const value = 42; | ||
|
||
export { value }; |
13 changes: 13 additions & 0 deletions
13
test/form/samples/reexport-external-default-and-name/_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,13 @@ | ||
var bundle = (function (exports, external) { | ||
'use strict'; | ||
|
||
external = external && external.hasOwnProperty('default') ? external['default'] : external; | ||
|
||
const value = 42; | ||
|
||
exports.default = external; | ||
exports.value = value; | ||
|
||
return exports; | ||
|
||
}({}, external)); |
13 changes: 13 additions & 0 deletions
13
test/form/samples/reexport-external-default-and-name/_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,13 @@ | ||
System.register('bundle', ['external'], function (exports) { | ||
'use strict'; | ||
return { | ||
setters: [function (module) { | ||
exports('default', module.default); | ||
}], | ||
execute: function () { | ||
|
||
const value = exports('value', 42); | ||
|
||
} | ||
}; | ||
}); |
Oops, something went wrong.