feat: replace importScripts with dynamic import #5785
Merged
Merged
Conversation
- Use import.meta.env instead of process.env for Vite environment variables - Change worker type from 'classic' to 'module' to support ES module imports - Configure separate worker paths for dev (source files) and production (bundled files) - Add worker configuration with ES format and node polyfills in vite.config - Update worker file paths to use absolute paths from root - Configure viteStaticCopy to bundle worker files for production builds Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates all @codingame/monaco-vscode-* packages from v15.0.3 to v23.2.2 for Vite build system. Key changes: - Update @codingame/monaco-vscode-api, monaco-editor, and vscode packages to v23.2.2 - Add @codingame/esbuild-import-meta-url-plugin for proper worker asset loading in Vite - Add Proxy workaround in apidom.worker.js for v23.2.2 worker initialization - Add CustomLogger to control log levels (Info in dev, Warning in production) - Configure Vite optimizeDeps for CommonJS libraries (vscode-textmate, vscode-oniguruma) - Update editor worker path to use editor.worker.start.js Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…poc-2 # Conflicts: # .env # package-lock.json # package.json # src/plugins/editor-monaco/monaco-contribution/CustomLogger.js
Remove hoistTransitiveImports: false from Vite config to fix runtime error "Cannot access '_y' before initialization" in ApiDOMAggregateError. The default hoisting behavior properly handles circular dependencies in ApiDOM. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Update build scripts in package.json to use Vite instead of Webpack - Add Vite config files for app, ESM, and UMD builds - Add build-bundle-umd.js script for UMD bundle generation - Update CLAUDE.md with condensed Vite-based documentation - Add required dev dependencies (vite plugins, memfs) - Update package-lock.json with new dependencies Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Remove memfs polyfill override that caused "Class extends value undefined" error due to missing Node.js-specific classes (FileHandle) in browser environment - Add minimal fs-shim.js polyfill to allow bundling of @asyncapi/parser without runtime filesystem dependencies - Configure workers (apidom.worker.js, editor.worker.js) as separate build entry points and place at root for proper loading - Add vite-plugin-static-copy to copy tree-sitter WASM files to build root where web-tree-sitter expects them - Add WASM plugin to worker rollup configuration for proper WASM handling in worker contexts - Update nodePolyfills config to exclude 'fs' instead of overriding with memfs This resolves runtime errors when running the production build including: - TypeError: Class extends value undefined is not a constructor - Failed to load module script (workers) - WebAssembly MIME type and compile errors Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
# Conflicts: # .env # CLAUDE.md # package-lock.json # package.json # test/cypress/static/index.html
…oints - Remove vite-plugin-top-level-await (incompatible with Vite 8 / Rollup 4) - Remove @rollup/plugin-wasm from rollupOptions in vite.config.app.js (conflicts with assetsInclude wasm handling) - Remove incorrect tree-sitter.wasm viteStaticCopy target - Change editor worker entry from editor.worker.start.js to editor.worker.js in all build configs (app, esm, umd) - Update external check in vite.config.esm.js to match new entry filename - Update vite and companion packages to latest versions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix vite.config.esm.js and vite.config.umd.js to use named dirname import instead of undefined path.dirname - Fix vite.config.js viteStaticCopy to copy editor.worker.js (not .start.js) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…olyfill-node - Remove vite-plugin-node-polyfills (incompatible with Vite 8) - Add rollup-plugin-polyfill-node to rollupOptions in vite.config.js, vite.config.app.js, and vite.config.umd.js (mainConfig) - Remove Node built-in externals (fs, path, http, https, zlib) from vite.config.js and vite.config.umd.js — now covered by polyfill - Remove fs alias shim from vite.config.app.js resolve.alias - Remove externalized-module onwarn suppressions no longer needed - Keep vite.config.esm.js unchanged (library build externalizes Node builtins) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Drop @esbuild-plugins/node-globals-polyfill (incompatible with Vite 8
Rolldown-based dep optimizer; esbuildOptions is now deprecated)
- Add inline fs-shim plugin to optimizeDeps.rolldownOptions.plugins so
it resolves 'fs' before rollup-plugin-polyfill-node's stub (which
lacks readFile, breaking @asyncapi/parser)
- Add define: { global: 'globalThis' } for dev-time global injection
- Restore fs alias in resolve.alias for vite.config.js and
vite.config.app.js (covers non-optimizeDeps resolution paths)
- Migrate optimizeDeps from deprecated esbuildOptions to rolldownOptions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace viteStaticCopy (which intercepted apidom.worker.js before Vite could transform bare specifiers) with correct worker dispatch: apidom worker via URL (Vite transform handles it), editor worker via ?worker import (required for node_modules rewriting). Remove dead getWorkerUrl fallback, unused VITE_EDITOR_WORKER_* env vars, and unresolvable optimizeDeps entries. Add docs/workers.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…esolution Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gression Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace ?raw imports with standard Vite asset imports so the GIF and SVG are served as URLs. Import version directly from package.json instead of the defunct webpack DefinePlugin PACKAGE_VERSION global. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add customLogger (dev/build plugin-level) and onwarn (rollup-level) to all four Vite configs to suppress externalized-module warnings from avsc, web-tree-sitter, and spectral, plus EMPTY_IMPORT_META and EVAL warnings from Monaco VSCode API and web-tree-sitter respectively. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sumers - Inject Module['wasmBinary'] via renderChunk for tree-sitter.wasm so emscripten's getBinaryPromise() bypasses fetch entirely; avoids the broken @rollup/plugin-wasm fetch interceptor whose endsWith() check matches the data URI against itself when the literal is replaced - Add inlineGrammarWasms Vite plugin that redirects grammar WASM imports (tree-sitter-yaml, tree-sitter-json) to virtual module IDs not ending in '.wasm', preventing @rollup/plugin-wasm's transform hook from converting them to incompatible loader functions; Language.load() receives Uint8Arrays directly instead - Switch apidom worker loading to ?worker import (removes env-var paths) - Add docs/wasm-bundling.md documenting the root causes and fixes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- dist/esm workers now built as ES modules (formats: ['es']) and spawned
with { type: 'module' }; dist/umd workers remain IIFE for Webpack compat
- merge inlineTreeSitterWasm + inlineGrammarWasms into a single inlineAllWasms
plugin (resolveId/load/renderChunk) shared via vite.config.shared.js
- extract shared logger, sharedOnwarn, inlineAllWasms to vite.config.shared.js
imported by both esm and umd configs to remove duplication
- remove unused @rollup/plugin-wasm and vite-plugin-wasm devDependencies
- update docs/workers.md and docs/wasm-bundling.md to reflect new approach
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
inlineDynamicImports in rollupOptions.output is deprecated in Vite 8 (Rolldown). codeSplitting:false at the build level is the replacement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Worker configs that use inlineAllWasms intercept .wasm imports via resolveId before Vite's asset pipeline, making assetsInclude:['**/*.wasm'] a no-op in those configs. Remove it from all six worker build entries. Configs that bundle apidom code without inlineAllWasms (UMD mainConfig, app build, dev server) still need assetsInclude to prevent Rolldown's builtin:vite-wasm-fallback from failing on .wasm imports. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract all custom plugins and shared utilities out of the config files: vite/shared.js — logger, sharedOnwarn vite/plugins/inline-all-wasms.js — WASM inlining plugin vite/plugins/rewrite-editor-worker-import.js — ?worker virtual modules vite/plugins/fix-cross-chunk-paths.js — relative import rewriting Remove vite.config.shared.js (superseded by vite/shared.js + vite/plugins/inline-all-wasms.js). Complete migration of vite.config.umd.js which still had local copies of all four utilities. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…LE from .env Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…N_URL from .env Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…to plugin array Move nodePolyfills from rollup plugins to Vite plugin array with enforce:'pre' so it wins module-resolution ahead of Vite's browser-externalization. Add fs-shim plugin to vite.config.app.js mirroring the dev config. Polyfill Buffer on worker globalThis to satisfy deep-extend's CJS global reference. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- makeCreate now returns a synchronous Proxy; an async IIFE loads the custom worker module via dynamic import() (ESM path) or importScripts (classic worker fallback). All method calls are deferred through instancePromise.then() — Monaco's existing Promise.resolve() wrapping in EditorWorker.$fmr picks them up transparently. - Consumer extension scripts should export customApiDOMWorkerFactory as a named export; globalThis assignment remains supported as a fallback. - Remove redundant apidom.worker / editor.worker Rollup input entries from vite.config.app.js — both workers are now built exclusively via the ?worker imports in after-load.js. Add [hash] to worker output filenames for cache busting. - Fix ./filename prefix in rewrite-editor-worker-import virtual module so webpack consumers' ReplaceAssetNamePlugin can locate and rewrite the plain worker filename to its hashed build output. - Update docs/workers.md and editor-monaco-language-apidom.md to reflect all of the above. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove importScripts mention from dynamic extension description - Replace globalThis.onmessage wrapper with direct initialize() call in both static extension examples, matching how apidom.worker.js itself bootstraps the worker - Broaden static extension intro from webpack-only to any bundler Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add publicDir: false to vite.config.esm.js, vite.config.umd.js, and all four worker build configs to prevent public/ assets from leaking into dist/esm/ and dist/umd/. Also enable sourcemaps for ESM worker builds and add rewriteEditorWorkerImport to the UMD config to eliminate duplicate hashed worker files in dist/umd/assets/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace cypress.config.js with playwright.config.ts, and exclude /vite/, /test-results/, /coverage/, tsconfig.json, and CLAUDE.md from the published package. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nore Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
glowcloud
approved these changes
May 19, 2026
swagger-bot
pushed a commit
that referenced
this pull request
May 19, 2026
# [5.5.0](v5.4.1...v5.5.0) (2026-05-19) ### Features * replace importScripts with dynamic import ([#5785](#5785)) ([465f017](465f017))
Contributor
|
🎉 This PR is included in version 5.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tsconfig.jsonformoduleResolution: \"bundler\"(correct for Vite), removing deprecatedbaseUrland adding CSS/SCSS ambient module declarationsTest plan
npm start— dev server starts, editor loads, Monaco workers load correctlynpm run build:app— standalone app builds to/buildnpm run build:bundle:esm— ESM bundle builds to/dist/esmnpm run build:bundle:umd— UMD bundle builds to/dist/umdnpm run build:definitions— TypeScript declarations emit to/dist/typeswithout errorsnpm run test:run— Vitest unit tests passnpx playwright test— E2E tests pass against dev servercustomApiDOMWorkerPathextension works in an ESM worker context🤖 Generated with Claude Code