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

core_1.createCompiler is not a function #364

Open
rexizam opened this issue Dec 20, 2023 · 1 comment
Open

core_1.createCompiler is not a function #364

rexizam opened this issue Dec 20, 2023 · 1 comment

Comments

@rexizam
Copy link

rexizam commented Dec 20, 2023

OS: Kubuntu 23.10
Node: 18
@nx: 16.9.1
@nx/rspack: 17.2.1
@rspack/core: 0.4.3

I'm running rspack in an NX monorepo, when I try to build my app with @nx/rspack I get the following error which originates from node_modules/@nx/rspack/src/utils/create-compiler.js:14:42

TypeError: (0 , core_1.createCompiler) is not a function
    at /home/toch/WebstormProjects/instrument/node_modules/@nx/rspack/src/utils/create-compiler.js:14:42
    at Generator.next (<anonymous>)
    at fulfilled (/home/toch/WebstormProjects/instrument/node_modules/tslib/tslib.js:114:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

My project configuration is the following:

"build": {
      "executor": "@nx/rspack:rspack",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": {
        "target": "web",
        "outputPath": "dist/apps/instrument-ui",
        "main": "apps/instrument-ui/src/index.tsx",
        "indexHtml": "apps/instrument-ui/src/index.html",
        "tsConfig": "apps/instrument-ui/tsconfig.app.json",
        "rspackConfig": "apps/instrument-ui/rspack.config.js",
        "assets": []
      },
      "configurations": {
        "development": {
          "mode": "development"
        },
        "production": {
          "mode": "production",
          "optimization": true,
          "sourceMap": false
        }
      }
    },
module.exports = composePlugins(withNx(), withReact(), (config, { options, context }) => {
  const testMode = context?.taskGraph?.roots[0]?.includes("e2e");
  const isProduction = options?.mode === "production";
  process.env.NX_E2E = `${testMode}`;

  return {
    ...config,
    entry: {
      main: {
        import: `${config.entry?.main?.import}`,
        runtime: "runtime",
        publicPath: "auto",
      },
      ...(isProduction && {
        polyfills: [`${config.context}/apps/instrument-ui/src/polyfills.ts`],
      }),
    },
    devServer: {
      ...config.devServer,
      allowedHosts: "all",
      client: {
        ...(config.devServer?.client ?? {}),
        ...(testMode && { overlay: false }),
        ...(!testMode && {
          overlay: {
            errors: true,
            warnings: false,
            runtimeErrors: true,
          },
        }),
      },
      hot: !isProduction,
      historyApiFallback: true,
      port: options?.devServer?.port ?? "auto",
      watchFiles: ["./src", `${config.context}/packages`],
    },
    plugins: getPlugins(config, isProduction),
    resolve: {
      ...config.resolve,
      fallback: {
        ...config.resolve.fallback,
        path: false,
      },
    },
  };
});
@wSedlacek
Copy link

This is caused by using the wrong version of rspack.

This PR fixed it so that 0.4.0 is compatible.
#352

However I have had some issues with that version, namely @nrwl/[email protected] is not published (Note: @nx/[email protected] is.

Issues with the typescript loader.

storage-buffer: ERROR in ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@nestjs_v52fed3lmsl5difqyigoj4pgxq/node_modules/@nestjs/terminus/dist/utils/promise-timeout.d.ts ModuleParseError
storage-buffer:   × Module parse failed:
storage-buffer:   ╰─▶   × JavaScript parsing error
storage-buffer:          ╭─[5:1]
storage-buffer:        5 │  * @internal
storage-buffer:        6 │  */
storage-buffer:        7 │ export declare class TimeoutError extends Error {
storage-buffer:          ·                ──┬──
storage-buffer:          ·                  ╰── Expected ',', got 'class'
storage-buffer:        8 │ }
storage-buffer:        9 │ /**
storage-buffer:          ╰────
storage-buffer:       
storage-buffer:   help: 
storage-buffer:         You may need an appropriate loader to handle this file type.

For now I just use

    "@nx/rspack": "17.2.2”,
    "@rspack/core": "~0.3.14",
    "@rspack/dev-server": "~0.3.14",
    "@rspack/plugin-minify": "~0.3.14",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants