-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Parcel example doesn't work with new monaco-editor versions (#433)
- Patch monaco-editor in order to get esm-parcel sample working - Aside: Looks like CI didn't catch this? - Fix both `0.45.0` and `0.46.0` monaco-editor versions resolve in the repo - Bumped parcel version - Replaces `~0.46.0` monaco-editor versions with `^0.46.0` for consistency, and so we don't need 2 lines in packages.json#resolutions This seems like more of a Parcel issue than a monaco-editor one, so I've opened an issue on them: parcel-bundler/parcel#9549
- Loading branch information
Showing
6 changed files
with
595 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
diff --git a/esm/vs/base/common/platform.js b/esm/vs/base/common/platform.js | ||
index d507327daec3cdf5027bd886f898c364c5433ecd..9dc769654606b60bc71922dd40f2146db97dcbb9 100644 | ||
--- a/esm/vs/base/common/platform.js | ||
+++ b/esm/vs/base/common/platform.js | ||
@@ -26,9 +26,11 @@ if (typeof $globalThis.vscode !== 'undefined' && typeof $globalThis.vscode.proce | ||
// Native environment (sandboxed) | ||
nodeProcess = $globalThis.vscode.process; | ||
} | ||
-else if (typeof process !== 'undefined') { | ||
+// Work around bug in Parcel causing $globalThis.process !== process | ||
+// https://github.com/parcel-bundler/parcel/issues/9549 | ||
+else if (typeof $globalThis.process !== 'undefined') { | ||
// Native environment (non-sandboxed) | ||
- nodeProcess = process; | ||
+ nodeProcess = $globalThis.process; | ||
} | ||
const isElectronProcess = typeof ((_a = nodeProcess === null || nodeProcess === void 0 ? void 0 : nodeProcess.versions) === null || _a === void 0 ? void 0 : _a.electron) === 'string'; | ||
const isElectronRenderer = isElectronProcess && (nodeProcess === null || nodeProcess === void 0 ? void 0 : nodeProcess.type) === 'renderer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
# Monaco Kusto Parcel example | ||
|
||
See [../../README.md] for general esm setup instructions | ||
|
||
## Parcel-specific changes | ||
|
||
### Add `{ "alias": { "process": false } }` to `package.json` | ||
|
||
@kusto/language-server includes node-specific code. Configure Parcel avoiding including `node_modules/process` in our bundle. | ||
|
||
Parcel docs on disabling `process` shimming: https://parceljs.org/features/dependency-resolution/#package-aliases | ||
Parcel docs on shimming globals: https://parceljs.org/features/node-emulation/#shimming-builtin-node-globals | ||
|
||
### Patch monaco-editor to use globalThis.process instead of process | ||
|
||
Recent monaco versions use `typeof process` to check if it's running in a node environment. Parcel doesn't have the ability to make this check return `false` so we need to patch monaco to use `globalThis.process` instead. | ||
|
||
The yarn patch file this repo uses can be seen at `/.yarn/patches/monaco-editor-npm-0.46.0-fb69b10c11.patch`. | ||
|
||
Yarn docs for patching packages: https://yarnpkg.com/cli/patch | ||
|
||
Parcel issue tracking this: https://github.com/parcel-bundler/parcel/issues/9549 |
Oops, something went wrong.