Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(builder-plugin-swc): properly handle transform error in loader #2900

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/metal-bikes-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/builder-plugin-swc': patch
---

fix(builder-plugin-swc): properly handle transform error in loader

fix(builder-plugin-swc): 处理 loader 中的编译异常
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
packages/runtime/plugin-garfish/tests/**
tests/integration/swc/fixtures/transform-fail/src/App.jsx
1 change: 1 addition & 0 deletions packages/builder/plugin-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"types": "./src/index.ts",
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"test": "vitest run",
"test:watch": "vitest dev --no-coverage",
"test:update": "SNAPSHOT_UPDATE=1 vitest watch",
Expand Down
8 changes: 6 additions & 2 deletions packages/builder/plugin-swc/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export function createLoader() {
compiler = new Compiler(options);
}

const result = await compiler.transform(filename, code, map);
resolve(null, result.code, result.map?.toString());
try {
const result = await compiler.transform(filename, code, map);
resolve(null, result.code, result.map?.toString());
} catch (err) {
resolve(err as Error);
}
};
}

Expand Down
Loading