From 7a74b2770e7024e53fbcf5ca8f470629e5839ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Tue, 13 Feb 2024 15:43:47 +0100 Subject: [PATCH] fix: transform monaco import from monaco-emacs/vim to be esm strict compliant --- rollup.config.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rollup.config.ts b/rollup.config.ts index 8d010f9..ff64d8f 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -9,6 +9,7 @@ import vsixPlugin from '@codingame/monaco-vscode-rollup-vsix-plugin' import glob from 'fast-glob' import path from 'path' import pkg from './package.json' assert { type: 'json' } +import { addExtension } from '@rollup/pluginutils' const externals = Object.keys(pkg.dependencies) @@ -43,6 +44,20 @@ export default rollup.defineConfig({ { name: 'external-resolver', resolveId (id) { + // monaco-editor can safely be imported with monaco-vscode-api + if (id === 'monaco-editor/esm/vs/editor/editor.api') { + return { + id: 'monaco-editor', + external: 'absolute' + } + } + // Add missing .js extension to respect ESM strict mode + if (id.startsWith('monaco-editor/esm')) { + return { + id: addExtension(id, '.js'), + external: 'absolute' + } + } if (/\.wasm$/.test(id) || externals.some(external => id === external || id.startsWith(`${external}/`))) { return { id,