-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: this.emitFile support prebuilt-chunk type (#4990)
* feat: this.emitFile support prebuilt-chunk type * feat: optimize * test: add more test * chore: tweak * docs: update documentation * docs: update * Refine docs * Minor type refinement --------- Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com> Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
- Loading branch information
1 parent
0ee31f1
commit 06e9045
Showing
12 changed files
with
285 additions
and
30 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
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
22 changes: 22 additions & 0 deletions
22
test/function/samples/emit-file/invalid-prebuilt-chunk-filename/_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,22 @@ | ||
module.exports = defineTest({ | ||
description: 'throws for invalid prebuilt chunks filename', | ||
options: { | ||
plugins: { | ||
name: 'test-plugin', | ||
buildStart() { | ||
this.emitFile({ | ||
type: 'prebuilt-chunk', | ||
code: 'console.log("my-chunk")' | ||
}); | ||
} | ||
} | ||
}, | ||
error: { | ||
code: 'PLUGIN_ERROR', | ||
hook: 'buildStart', | ||
message: | ||
'The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "undefined".', | ||
plugin: 'test-plugin', | ||
pluginCode: 'VALIDATION_ERROR' | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
test/function/samples/emit-file/invalid-prebuilt-chunk-filename/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 @@ | ||
throw new Error('should not build'); |
21 changes: 21 additions & 0 deletions
21
test/function/samples/emit-file/invalid-prebuit-chunk-code/_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,21 @@ | ||
module.exports = defineTest({ | ||
description: 'throws for invalid prebuilt chunks code', | ||
options: { | ||
plugins: { | ||
name: 'test-plugin', | ||
buildStart() { | ||
this.emitFile({ | ||
type: 'prebuilt-chunk', | ||
fileName: 'my-chunk.js' | ||
}); | ||
} | ||
} | ||
}, | ||
error: { | ||
code: 'PLUGIN_ERROR', | ||
hook: 'buildStart', | ||
message: 'Emitted prebuilt chunks need to have a valid string code, received "undefined".', | ||
plugin: 'test-plugin', | ||
pluginCode: 'VALIDATION_ERROR' | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
test/function/samples/emit-file/invalid-prebuit-chunk-code/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 @@ | ||
throw new Error('should not build'); |
Oops, something went wrong.