arackaf / customize-cra

Override webpack configurations for create-react-app 2.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

__webpack_require__(...) is not a function

polisen opened this issue · comments

Hey - I'm using customize-cra and react-app-rewired to override the webpack config usually abstracted away in a create-react-app.

I'm importing the random-int package to the worker file - which is the import that fails.

config-overrides.js

const { override, addWebpackModuleRule, babelInclude } = require("customize-cra");
const path = require('path')
module.exports = override(
  addWebpackModuleRule({
    test: /\.worker\.(js|ts)$/i,
    use: [
      {
        loader: "comlink-loader",
        options: {
          singleton: true,
        },
      },
    ],
  })
);

This is the correct syntax - but now it complains about that webpack doesn't have a require function - which is to be expected. Supposedly something wasn't transpiled by babel but I can't figure out where to even begin.

Do you geniuses have any idea?