import resolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import rust from "@wasm-tool/rollup-plugin-rust";
import { terser } from "rollup-plugin-terser";

const plugins = [
  babel({
    exclude: "node_modules/**",
    babelHelpers: "bundled",
    presets: ["solid"]
  }),
  resolve({ extensions: [".js", ".jsx"] }),
  rust({ inlineWasm: true })
];

export default {
  input: "src/index.js",
  output: [
    {
      file: "dist/index.js",
      format: "es"
    },
    {
      file: "public/bundle.js",
      format: "iife",
      name: "AsciinemaPlayer"
    },
    {
      file: "public/bundle.min.js",
      format: "iife",
      name: "AsciinemaPlayer",
      plugins: [terser()]
    }
  ],
  plugins
};

@@ -184,16 +184,512 @@
 rser%22;%0A%0A
+function removeImportMetaUrl() %7B%0A  // This plugin replaces import.meta.url with an empty string. Why?%0A  // wasm-bindgen produces a wasm loading code having reference to%0A  // import.meta.url, which becomes a dead code given rust plugin inlines the%0A  // wasm blob, while import.meta.url triggers bundling issues with popular%0A  // bundlers (or requires plugins).%0A%0A  return %7B%0A    resolveImportMeta(property, %7BmoduleId%7D) %7B%0A      if (property === 'url') %7B return %22''%22 %7D%0A      return null;%0A    %7D%0A  %7D%0A%7D%0A%0A
 const pl
@@ -870,16 +870,41 @@
  true %7D)
+,%0A  removeImportMetaUrl()
 %0A%5D;%0A%0Aexp

Remove import.meta.url from the output bundles