lezer-parser / lezer

Dev utils and issues for the Lezer core packages
33 stars 1 forks source link

Can't resolve 'process/browser' #38

Closed Dazaer closed 1 year ago

Dazaer commented 1 year ago
ERROR in ./node_modules/@lezer/lr/dist/index.js 911:23-30
Module not found: Error: Can't resolve 'process/browser' in '.../node_modules/@lezer/lr/dist'
Did you mean 'browser.js'?
BREAKING CHANGE: The request 'process/browser' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
ERROR in ./node_modules/@lezer/lr/dist/index.js
Cannot read properties of undefined (reading 'module')

My project is using es6 modules and I'm getting the above error.

I solve it currently by specifying the following in my webpack config:

  resolve: {
    fallback: {
      'process/browser': false,
    }
  },

Am I doing something wrong? Or is this something that has to be implemented/fixed/upgraded on lezer side?

marijnh commented 1 year ago

There is no mention to process/browser in this package's sources or build output, so I have no idea where this error could be coming from. What does line 911 in your ./node_modules/@lezer/lr/dist/index.js look like?

Dazaer commented 1 year ago
// Environment variable used to control console output
const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
marijnh commented 1 year ago

I guess you have some kind of magic in your build process that attemps to inject a polyfill for Node's process global into the build output because that line references it. The solution would be to find and turn off that magic.

Dazaer commented 1 year ago

In case anyone else stumbles into this here's what I changed to solved it:

    new webpack.ProvidePlugin({
      process: 'process/browser'
    })

Changing the value to process or process/browser.js works the same.