Skip to content

Commit

Permalink
[v3.0] Run output plugins last (#3846)
Browse files Browse the repository at this point in the history
* fix: run output plugins last

* Add test

Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
  • Loading branch information
aleclarson and lukastaegert committed Jul 29, 2022
1 parent 79e18b3 commit 465dbb4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/PluginDriver.ts
Expand Up @@ -105,7 +105,7 @@ export class PluginDriver {
this.finaliseAssets = this.fileEmitter.finaliseAssets.bind(this.fileEmitter);
this.setChunkInformation = this.fileEmitter.setChunkInformation.bind(this.fileEmitter);
this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter);
this.plugins = userPlugins.concat(basePluginDriver ? basePluginDriver.plugins : []);
this.plugins = (basePluginDriver ? basePluginDriver.plugins : []).concat(userPlugins);
const existingPluginNames = new Set<string>();

this.pluginContexts = new Map(
Expand Down
23 changes: 23 additions & 0 deletions test/form/samples/runs-output-plugins-last/_config.js
@@ -0,0 +1,23 @@
module.exports = {
description: 'runs output plugins last',
options: {
plugins: [
{
name: 'input',
renderChunk(code) {
return `/* input */\n${code}\n/* input */`;
}
}
],
output: {
plugins: [
{
name: 'output',
renderChunk(code) {
return `/* output */\n${code}\n/* output */`;
}
}
]
}
}
};
7 changes: 7 additions & 0 deletions test/form/samples/runs-output-plugins-last/_expected.js
@@ -0,0 +1,7 @@
/* output */
/* input */
let foo = 'base';

export { foo };
/* input */
/* output */
1 change: 1 addition & 0 deletions test/form/samples/runs-output-plugins-last/main.js
@@ -0,0 +1 @@
export let foo = 'base';
4 changes: 2 additions & 2 deletions test/function/samples/options-in-renderstart/_config.js
Expand Up @@ -22,10 +22,10 @@ module.exports = {
},
exports: () => {
assert.deepStrictEqual(checkedOptions, [
'output-plugin',
'input-plugin',
'cjs',
'global',
'input-plugin',
'output-plugin',
'cjs',
'global'
]);
Expand Down

0 comments on commit 465dbb4

Please sign in to comment.