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

Version 0.26.0 breaks webpack build: Can't resolve 'path' in .../monaco-editor/esm/vs/language/json/_deps/minimatch #2578

Closed
akphi opened this issue Jul 15, 2021 · 5 comments · May be fixed by MarcelRaschke/monaco-editor#22
Labels
bug Issue identified by VS Code Team member as probable bug json
Milestone

Comments

@akphi
Copy link

akphi commented Jul 15, 2021

Issue

We are using monaco-editor and monaco-editor-webpack-plugin in our codebase. When we upgrade from monaco-editor@0.25.2 to 0.26.0 and we got a failure when building the app in webpack:

ModuleNotFoundError: Module not found: Error: Can't resolve 'path' in '/Users/<username>/projects/legend/studio/node_modules/monaco-editor/esm/vs/language/json/_deps/minimatch'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
	- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "path": false }

I looked at the file monaco-editor/esm/vs/language/json/_deps/minimatch and I see this:

var path = { sep: '/' }
try {
  path = require('path')
} catch (er) {}

I'm afraid Webpack might look past the try .. catch block and yell about path there. Right now my workaround is as suggested in the error message, that is to add resolve.fallback: { "path": false }. I just wonder if this is something you would fix or would you recommend me to look for the answer from the webpack side instead?

Environment

monaco-editor version: 0.26.0
Browser: Chrome Version 91.0.4472.114 (Official Build) (x86_64)
OS: Mac OSX 11.4
Webpack: 5.44.0
monaco-editor-webpack-plugin: 4.1.0

@troy351
Copy link
Contributor

troy351 commented Jul 16, 2021

Also at the official site https://microsoft.github.io/monaco-editor/, change language to json shows error in console
image

@lsaccoz
Copy link

lsaccoz commented Jul 16, 2021

Also at the official site https://microsoft.github.io/monaco-editor/, change language to json shows error in console
image

Been pulling my hair out over this issue in my app since this afternoon. Seems like it's a general issue then.

@troy351
Copy link
Contributor

troy351 commented Jul 16, 2021

Seems caused by new added minimatch microsoft/monaco-json@4c5bfeb
@aeschli any ideas?

@hediet
Copy link
Member

hediet commented Jul 16, 2021

Thanks for reaching out! I had a minimatch related error when publishing monaco-json, but @aeschli fixed it.
Seems like there is something missing. I'll investigate - sorry for the inconvenience.

@hediet hediet added bug Issue identified by VS Code Team member as probable bug json labels Jul 16, 2021
@hediet hediet added this to the June 2021 milestone Jul 16, 2021
@hediet hediet closed this as completed in 34888a7 Jul 16, 2021
@hediet
Copy link
Member

hediet commented Jul 16, 2021

We temporarily reverted monaco-json back to 3.5.0 and published 0.26.1.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug json
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants