Skip to content

Commit

Permalink
fix: transform monaco import from monaco-emacs/vim to be esm strict c…
Browse files Browse the repository at this point in the history
…ompliant
  • Loading branch information
Loïc Mangeonjean committed Feb 13, 2024
1 parent 8e01bf3 commit 7a74b27
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7a74b27

Please sign in to comment.