lezer-parser/lezer

Can't resolve 'process/browser'

Dazaer opened this issue · 4 comments

Dazaer commented
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?

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
// Environment variable used to control console output
const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);

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

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.