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
18 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/_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,34 @@ | ||
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: 'entry-[name]-[format]-[ext][extname][assetExtname].mjs' | ||
}, | ||
plugins: [ | ||
{ | ||
resolveId(id) { | ||
if (id === '\0virtualModule') return id; | ||
if (id === '\0virtualWithExt.js') return id; | ||
if (id === '\0virtualWithAssetExt.str') return id; | ||
}, | ||
load(id) { | ||
if (id === '\0virtualModule') return 'export const virtual = "Virtual!";\n'; | ||
if (id === '\0virtualWithExt.js') return 'export const virtual2 = "Virtual2!";\n'; | ||
if (id === '\0virtualWithAssetExt.str') return 'export const virtual3 = "Virtual3!";\n'; | ||
}, | ||
transform(code, id) { | ||
if (id === '\0virtualModule') return null; | ||
if (id === '\0virtualWithExt.js') return null; | ||
if (id === '\0virtualWithAssetExt.str') return null; | ||
return ( | ||
'import {virtual} from "\0virtualModule";\nimport {virtual2} from "\0virtualWithExt.js";\nimport {virtual3} from "\0virtualWithAssetExt.str";' + | ||
code | ||
); | ||
} | ||
} | ||
] | ||
} | ||
}; |
9 changes: 9 additions & 0 deletions
9
...les-virtual-modules-filename-pattern/_expected/amd/_virtual/entry-_virtualModule-amd-.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 }); | ||
|
||
})); |
9 changes: 9 additions & 0 deletions
9
...es-filename-pattern/_expected/amd/_virtual/entry-_virtualWithAssetExt-amd-str.str.str.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 virtual3 = "Virtual3!"; | ||
|
||
exports.virtual3 = virtual3; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
})); |
9 changes: 9 additions & 0 deletions
9
...rtual-modules-filename-pattern/_expected/amd/_virtual/entry-_virtualWithExt-amd-js.js.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 virtual2 = "Virtual2!"; | ||
|
||
exports.virtual2 = virtual2; | ||
|
||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
|
||
})); |
7 changes: 7 additions & 0 deletions
7
.../preserve-modules-virtual-modules-filename-pattern/_expected/amd/entry-main-amd-js.js.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 @@ | ||
define(['./_virtual/entry-_virtualModule-amd-.mjs', './_virtual/entry-_virtualWithExt-amd-js.js.mjs', './_virtual/entry-_virtualWithAssetExt-amd-str.str.str.mjs'], (function (_virtualModule, _virtualWithExt, _virtualWithAssetExt) { 'use strict'; | ||
|
||
assert.equal(_virtualModule.virtual, 'Virtual!'); | ||
assert.equal(_virtualWithExt.virtual2, 'Virtual2!'); | ||
assert.equal(_virtualWithAssetExt.virtual3, 'Virtual3!'); | ||
|
||
})); |
7 changes: 7 additions & 0 deletions
7
...les-virtual-modules-filename-pattern/_expected/cjs/_virtual/entry-_virtualModule-cjs-.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; |
7 changes: 7 additions & 0 deletions
7
...es-filename-pattern/_expected/cjs/_virtual/entry-_virtualWithAssetExt-cjs-str.str.str.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 virtual3 = "Virtual3!"; | ||
|
||
exports.virtual3 = virtual3; |
7 changes: 7 additions & 0 deletions
7
...rtual-modules-filename-pattern/_expected/cjs/_virtual/entry-_virtualWithExt-cjs-js.js.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 virtual2 = "Virtual2!"; | ||
|
||
exports.virtual2 = virtual2; |
9 changes: 9 additions & 0 deletions
9
.../preserve-modules-virtual-modules-filename-pattern/_expected/cjs/entry-main-cjs-js.js.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 @@ | ||
'use strict'; | ||
|
||
var _virtualModule = require('./_virtual/entry-_virtualModule-cjs-.mjs'); | ||
var _virtualWithExt = require('./_virtual/entry-_virtualWithExt-cjs-js.js.mjs'); | ||
var _virtualWithAssetExt = require('./_virtual/entry-_virtualWithAssetExt-cjs-str.str.str.mjs'); | ||
|
||
assert.equal(_virtualModule.virtual, 'Virtual!'); | ||
assert.equal(_virtualWithExt.virtual2, 'Virtual2!'); | ||
assert.equal(_virtualWithAssetExt.virtual3, 'Virtual3!'); |
3 changes: 3 additions & 0 deletions
3
...dules-virtual-modules-filename-pattern/_expected/es/_virtual/entry-_virtualModule-es-.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
...ules-filename-pattern/_expected/es/_virtual/entry-_virtualWithAssetExt-es-str.str.str.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 virtual3 = "Virtual3!"; | ||
|
||
export { virtual3 }; |
3 changes: 3 additions & 0 deletions
3
...virtual-modules-filename-pattern/_expected/es/_virtual/entry-_virtualWithExt-es-js.js.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 virtual2 = "Virtual2!"; | ||
|
||
export { virtual2 }; |
7 changes: 7 additions & 0 deletions
7
...es/preserve-modules-virtual-modules-filename-pattern/_expected/es/entry-main-es-js.js.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 @@ | ||
import { virtual } from './_virtual/entry-_virtualModule-es-.mjs'; | ||
import { virtual2 } from './_virtual/entry-_virtualWithExt-es-js.js.mjs'; | ||
import { virtual3 } from './_virtual/entry-_virtualWithAssetExt-es-str.str.str.mjs'; | ||
|
||
assert.equal(virtual, 'Virtual!'); | ||
assert.equal(virtual2, 'Virtual2!'); | ||
assert.equal(virtual3, 'Virtual3!'); |
10 changes: 10 additions & 0 deletions
10
...rtual-modules-filename-pattern/_expected/system/_virtual/entry-_virtualModule-system-.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!"); | ||
|
||
}) | ||
}; | ||
})); |
10 changes: 10 additions & 0 deletions
10
...ename-pattern/_expected/system/_virtual/entry-_virtualWithAssetExt-system-str.str.str.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 virtual3 = exports('virtual3', "Virtual3!"); | ||
|
||
}) | ||
}; | ||
})); |
10 changes: 10 additions & 0 deletions
10
...modules-filename-pattern/_expected/system/_virtual/entry-_virtualWithExt-system-js.js.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 virtual2 = exports('virtual2', "Virtual2!"); | ||
|
||
}) | ||
}; | ||
})); |
20 changes: 20 additions & 0 deletions
20
...rve-modules-virtual-modules-filename-pattern/_expected/system/entry-main-system-js.js.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,20 @@ | ||
System.register(['./_virtual/entry-_virtualModule-system-.mjs', './_virtual/entry-_virtualWithExt-system-js.js.mjs', './_virtual/entry-_virtualWithAssetExt-system-str.str.str.mjs'], (function () { | ||
'use strict'; | ||
var virtual, virtual2, virtual3; | ||
return { | ||
setters: [function (module) { | ||
virtual = module.virtual; | ||
}, function (module) { | ||
virtual2 = module.virtual2; | ||
}, function (module) { | ||
virtual3 = module.virtual3; | ||
}], | ||
execute: (function () { | ||
|
||
assert.equal(virtual, 'Virtual!'); | ||
assert.equal(virtual2, 'Virtual2!'); | ||
assert.equal(virtual3, 'Virtual3!'); | ||
|
||
}) | ||
}; | ||
})); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/preserve-modules-virtual-modules-filename-pattern/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,3 @@ | ||
assert.equal(virtual, 'Virtual!'); | ||
assert.equal(virtual2, 'Virtual2!'); | ||
assert.equal(virtual3, 'Virtual3!'); |