Skip to content

The 'compilation' argument must be an instance of Compilation #35

@erwannbst

Description

@erwannbst

Hello,
I tried to use this plugin with Next but I get this error

> next dev

   ▲ Next.js 15.5.3
   - Local:        http://localhost:3000
   - Network:      http://192.168.1.181:3000
   - Environments: .env.local

 ✓ Starting...
TypeError: The 'compilation' argument must be an instance of Compilation
    at <unknown> (webpack://pyodide/webpack-plugin/index.ts:50:58)
  48 |         super.apply(compiler);
  49 |         compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
> 50 |             const compilationHooks = webpack.NormalModule.getCompilationHooks(compilation);
     |                                                          ^
  51 |             compilationHooks.beforeLoaders.tap(this.constructor.name, (loaders, normalModule) => {
  52 |                 const matches = normalModule.userRequest.match(/pyodide\.m?js$/);
  53 |                 if (matches) {

Here is my next.config.mjs :

/** @type {import('next').NextConfig} */
import { PyodidePlugin } from "@pyodide/webpack-plugin";

const nextConfig = {
  output: "export", // Outputs a Single-Page Application (SPA).
  distDir: "./dist", // Changes the build output directory to `./dist/`.
  webpack: (config) => {
    config.plugins.push(new PyodidePlugin());
    return config;
  },
};

export default nextConfig;

And the usage :

import { loadPyodide, version } from "pyodide";

const pyodideReadyPromise = loadPyodide({
  indexURL: `${window.location.origin}/pyodide`,
});

I also tried with globalLoadPyodide but can't manage to make it work...
Any ideas ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions