Skip to content

Commit

Permalink
fix: re-order tranform plugins (#6649)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia authored Nov 14, 2023
1 parent a0df6fa commit 58d8cb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-icons-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/shared-config': patch
---

fix: reoder transform plugins
4 changes: 2 additions & 2 deletions packages/shared-config/src/getCompilerPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function getPluginTransform(plugin: UnpluginOptions, transformOptions: Transform
const { transform } = plugin;
if (transform) {
return {
// Add default enfoce pre, so it will excute before swc compilation.
enforce: 'pre',
...plugin,
transform(code: string, id: string) {
return transform.call(this, code, id, transformOptions);
Expand Down Expand Up @@ -88,8 +90,6 @@ function getCompilerPlugins(rootDir: string, config: Config, compiler: Compiler,
}
if (clientBundlers.includes(compiler)) {
return compilerPlugins
// Plugins will be transformed as webpack loader, the execute order of webpack loader is reversed.
.reverse()
.map((plugin) => createUnplugin(() => getPluginTransform(plugin, transformOptions))[compiler]()) as Config['plugins'];
} else {
return compilerPlugins.map(plugin => getPluginTransform(plugin, transformOptions));
Expand Down

0 comments on commit 58d8cb8

Please sign in to comment.