From 849d676919176d92119ab68a97008ef81bc8aa45 Mon Sep 17 00:00:00 2001 From: lianghang <290425492@qq.com> Date: Sun, 8 Mar 2020 15:08:20 +0800 Subject: [PATCH 1/2] fix: monaco path by cwd --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index c2eeb08b..07fa2e8f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,7 @@ featuresArr.forEach(feature => featuresById[feature.label] = feature); * Return a resolved path for a given Monaco file. */ function resolveMonacoPath(filePath: string): string { - return require.resolve(path.join('monaco-editor/esm', filePath)); + return require.resolve(path.join(process.cwd(), 'node_modules', 'monaco-editor/esm', filePath)); } /** From 2ea08783c2c4ee159c7cdcd744d531540f8a2fe0 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 10 Mar 2020 10:11:59 +0100 Subject: [PATCH 2/2] Fall back to looking in node_modules folder in cwd --- src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 07fa2e8f..38690d65 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,11 @@ featuresArr.forEach(feature => featuresById[feature.label] = feature); * Return a resolved path for a given Monaco file. */ function resolveMonacoPath(filePath: string): string { - return require.resolve(path.join(process.cwd(), 'node_modules', 'monaco-editor/esm', filePath)); + try { + return require.resolve(path.join('monaco-editor/esm', filePath)); + } catch(err) { + return require.resolve(path.join(process.cwd(), 'node_modules/monaco-editor/esm', filePath)); + } } /**