Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support emitting files via manualChunks in output (#4761)
- Loading branch information
1 parent
7182a92
commit d750ef2
Showing
7 changed files
with
88 additions
and
8 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
27 changes: 27 additions & 0 deletions
27
test/function/samples/emit-chunk-manual-asset-source/_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,27 @@ | ||
const assert = require('node:assert'); | ||
let referenceId; | ||
|
||
module.exports = { | ||
description: 'supports setting asset sources as side effect of the manual chunks option', | ||
options: { | ||
output: { | ||
manualChunks: { foo: ['manual.js'] }, | ||
assetFileNames: '[name]-[hash][extname]' | ||
}, | ||
plugins: { | ||
transform(code, id) { | ||
if (id.endsWith('manual.js')) { | ||
referenceId = this.emitFile({ type: 'asset', name: 'emitted.txt' }); | ||
} | ||
}, | ||
moduleParsed({ id }) { | ||
if (id.endsWith('manual.js')) { | ||
this.setAssetSource(referenceId, 'emitted'); | ||
} | ||
}, | ||
generateBundle() { | ||
assert.strictEqual(this.getFileName(referenceId), 'emitted-f57bfbce.txt'); | ||
} | ||
} | ||
} | ||
}; |
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.ok(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 @@ | ||
import './main'; |
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 @@ | ||
const assert = require('node:assert'); | ||
let referenceId; | ||
|
||
module.exports = { | ||
description: 'supports emitting chunks as side effect of the manual chunks option', | ||
options: { | ||
output: { | ||
manualChunks: { foo: ['manual.js'] }, | ||
assetFileNames: '[name]-[hash][extname]' | ||
}, | ||
plugins: { | ||
transform(code, id) { | ||
if (id.endsWith('manual.js')) { | ||
referenceId = this.emitFile({ type: 'asset', name: 'emitted.txt', source: 'emitted' }); | ||
} | ||
}, | ||
generateBundle() { | ||
assert.strictEqual(this.getFileName(referenceId), 'emitted-f57bfbce.txt'); | ||
} | ||
} | ||
} | ||
}; |
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.ok(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 @@ | ||
import './main'; |