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: there is no debug hook in rollup 2 #53

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 14 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,20 @@ function createPlugin(globals, {include, exclude, dynamicWrapper = defaultDynami
return {
name: "rollup-plugin-external-globals",
options,
transform
transform,
};
function getDebug(context) {
return (err, message) => {
if (context.debug) {
context.debug({
message,
cause: err
});
} else if (context.warn) {
context.warn(message, err.loc ?? err.pos ?? null);
}
};
}
async function options(rawOptions) {
const plugins = Array.isArray(rawOptions.plugins)
? [...rawOptions.plugins]
Expand All @@ -59,10 +71,7 @@ function createPlugin(globals, {include, exclude, dynamicWrapper = defaultDynami
try {
ast = this.parse(code);
} catch (err) {
this.debug({
message: `Failed to parse code, skip ${id}`,
cause: err
});
getDebug(this)(err, `Failed to parse code, skip ${id}`);
return;
}
code = new MagicString(code);
Expand Down
Loading
Loading