Skip to content

Commit

Permalink
Remove workaround for import.meta.url bug in bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Mar 2, 2023
1 parent ad5dd16 commit e8217ef
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@ import babel from "@rollup/plugin-babel";
import resolve from "@rollup/plugin-node-resolve";
import rust from "@wasm-tool/rollup-plugin-rust";

function removeImportMetaUrl() {
// This plugin replaces import.meta.url with an empty string. Why?
// wasm-bindgen produces a wasm loading code having reference to
// import.meta.url, which becomes a dead code given rust plugin inlines the
// wasm blob, while import.meta.url causes bundling issues with popular
// bundlers (or requires plugins).

return {
resolveImportMeta(property, {moduleId}) {
if (property === 'url') { return "''" }
return null;
}
}
}

const plugins = [
babel({
exclude: "node_modules/**",
Expand All @@ -25,8 +10,7 @@ const plugins = [
plugins: [['@babel/transform-runtime']]
}),
rust({ inlineWasm: true, wasmOptArgs: ["-O4"] }),
resolve({ extensions: [".js", ".jsx"] }),
removeImportMetaUrl()
resolve({ extensions: [".js", ".jsx"] })
];

export default {
Expand Down

0 comments on commit e8217ef

Please sign in to comment.