Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new test for virtual file output when modifying entryFileNames
Use entryFileNames to change the extension of the filename to be mjs, and see that the file created from the virtual file chunk has a .mjs extension Note that the amd definition contains the .mjs extension, as amd ids only strip the .js file extension, which is slightly odd but probably ok as this amd is not the targetted usecase for this behaviour
- Loading branch information
Showing
10 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...chunking-form/samples/preserve-modules-virtual-modules-follows-entry-filenames/_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,23 @@ | ||
module.exports = { | ||
description: | ||
'Generates actual files whose filename adheres to entryFileNames for virtual modules when preserving modules', | ||
options: { | ||
input: 'main.js', | ||
output: { preserveModules: true, entryFileNames: '[name][assetExtname].mjs' }, | ||
plugins: [ | ||
{ | ||
resolveId(id) { | ||
if (id === '\0virtualModule') return id; | ||
}, | ||
load(id) { | ||
if (id !== '\0virtualModule') return null; | ||
return 'export const virtual = "Virtual!";\n'; | ||
}, | ||
transform(code, id) { | ||
if (id === '\0virtualModule') return null; | ||
return 'import {virtual} from "\0virtualModule";\n' + code; | ||
} | ||
} | ||
] | ||
} | ||
}; |
9 changes: 9 additions & 0 deletions
9
...modules-virtual-modules-follows-entry-filenames/_expected/amd/_virtual/_virtualModule.mjs
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,9 @@ | ||
define(['exports'], (function (exports) { 'use strict'; | ||
|
||
const virtual = "Virtual!"; | ||
|
||
exports.virtual = virtual; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
})); |
5 changes: 5 additions & 0 deletions
5
...m/samples/preserve-modules-virtual-modules-follows-entry-filenames/_expected/amd/main.mjs
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 @@ | ||
define(['./_virtual/_virtualModule.mjs'], (function (_virtualModule) { 'use strict'; | ||
|
||
assert.equal(_virtualModule.virtual, 'Virtual!'); | ||
|
||
})); |
7 changes: 7 additions & 0 deletions
7
...modules-virtual-modules-follows-entry-filenames/_expected/cjs/_virtual/_virtualModule.mjs
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 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
const virtual = "Virtual!"; | ||
|
||
exports.virtual = virtual; |
5 changes: 5 additions & 0 deletions
5
...m/samples/preserve-modules-virtual-modules-follows-entry-filenames/_expected/cjs/main.mjs
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 @@ | ||
'use strict'; | ||
|
||
var _virtualModule = require('./_virtual/_virtualModule.mjs'); | ||
|
||
assert.equal(_virtualModule.virtual, 'Virtual!'); |
3 changes: 3 additions & 0 deletions
3
...-modules-virtual-modules-follows-entry-filenames/_expected/es/_virtual/_virtualModule.mjs
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 @@ | ||
const virtual = "Virtual!"; | ||
|
||
export { virtual }; |
3 changes: 3 additions & 0 deletions
3
...rm/samples/preserve-modules-virtual-modules-follows-entry-filenames/_expected/es/main.mjs
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 @@ | ||
import { virtual } from './_virtual/_virtualModule.mjs'; | ||
|
||
assert.equal(virtual, 'Virtual!'); |
10 changes: 10 additions & 0 deletions
10
...ules-virtual-modules-follows-entry-filenames/_expected/system/_virtual/_virtualModule.mjs
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 @@ | ||
System.register([], (function (exports) { | ||
'use strict'; | ||
return { | ||
execute: (function () { | ||
|
||
const virtual = exports('virtual', "Virtual!"); | ||
|
||
}) | ||
}; | ||
})); |
14 changes: 14 additions & 0 deletions
14
...amples/preserve-modules-virtual-modules-follows-entry-filenames/_expected/system/main.mjs
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,14 @@ | ||
System.register(['./_virtual/_virtualModule.mjs'], (function () { | ||
'use strict'; | ||
var virtual; | ||
return { | ||
setters: [function (module) { | ||
virtual = module.virtual; | ||
}], | ||
execute: (function () { | ||
|
||
assert.equal(virtual, 'Virtual!'); | ||
|
||
}) | ||
}; | ||
})); |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/preserve-modules-virtual-modules-follows-entry-filenames/main.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 @@ | ||
assert.equal(virtual, 'Virtual!'); |