Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add assetExtname replacement in entryFileNames (#4077)
* Add assetExtname replacement in entryFileNames This only has an effect when preserveModules is enaled. This allows consumers who want to customise the entry file name to easily implement the "only add an extension for non js/ts files" logic that rollup does if you don't specify entryFileNames. * Update test snapshots * Fix linting Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
- Loading branch information
1 parent
b460516
commit 645cc5c
Showing
13 changed files
with
56 additions
and
7 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
19 changes: 17 additions & 2 deletions
19
test/chunking-form/samples/preserve-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 |
---|---|---|
@@ -1,10 +1,25 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
description: 'entryFileNames pattern supported in combination with preserveModules', | ||
options: { | ||
input: 'src/main.ts', | ||
output: { | ||
entryFileNames: 'entry-[name]-[format]-[ext][extname].js', | ||
entryFileNames: 'entry-[name]-[format]-[ext][extname][assetExtname].js', | ||
preserveModules: true | ||
} | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'str-plugin', | ||
transform(code, id) { | ||
switch (path.extname(id)) { | ||
case '.str': | ||
return { code: `export default "${code.trim()}"` }; | ||
default: | ||
return null; | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
...rm/samples/preserve-modules-filename-pattern/_expected/amd/entry-lorem-amd-str.str.str.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,7 @@ | ||
define(function () { 'use strict'; | ||
|
||
var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; | ||
|
||
return lorem; | ||
|
||
}); |
3 changes: 2 additions & 1 deletion
3
...king-form/samples/preserve-modules-filename-pattern/_expected/amd/entry-main-amd-ts.ts.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
5 changes: 5 additions & 0 deletions
5
...rm/samples/preserve-modules-filename-pattern/_expected/cjs/entry-lorem-cjs-str.str.str.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 @@ | ||
'use strict'; | ||
|
||
var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; | ||
|
||
module.exports = lorem; |
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
3 changes: 3 additions & 0 deletions
3
...form/samples/preserve-modules-filename-pattern/_expected/es/entry-lorem-es-str.str.str.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...unking-form/samples/preserve-modules-filename-pattern/_expected/es/entry-main-es-ts.ts.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as foo } from './entry-foo-es-ts.ts.js'; | ||
export { default as bar } from './nested/entry-bar-es-ts.ts.js'; | ||
export { default as baz } from './nested/entry-baz-es-ts.ts.js'; | ||
export { default as lorem } from './entry-lorem-es-str.str.str.js'; | ||
export { default as noExt } from './entry-no-ext-es-.js'; |
10 changes: 10 additions & 0 deletions
10
...ples/preserve-modules-filename-pattern/_expected/system/entry-lorem-system-str.str.str.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,10 @@ | ||
System.register([], function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
|
||
var lorem = exports('default', "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); | ||
|
||
} | ||
}; | ||
}); |
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
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/preserve-modules-filename-pattern/src/lorem.str
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 @@ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
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