Skip to content

Conversation

@fireairforce
Copy link

@fireairforce fireairforce commented Dec 14, 2025

使用 new URL('') 来替代 module import 去导入 wasm 产物,这样可以避免产物的 bundle 的体积 & 构建速度。

用 webpack 测试过,看上去使用上效果都是一样的。

Copilot AI review requested due to automatic review settings December 14, 2025 15:12
@changeset-bot
Copy link

changeset-bot bot commented Dec 14, 2025

⚠️ No Changeset found

Latest commit: 154dd6b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sunshinesmilelk
Copy link
Collaborator

👋 @fireairforce

💖 Thanks for opening this pull request! 💖

Please follow the contributing guidelines. And we use [semantic commit messages to streamline the release process.

Examples of commit messages with semantic prefixes:

  • fix(ai-native): fix cursor in chat
  • feat(lab): support for julia script editing and preview
  • docs: add sql cell manual

Things that will help get your PR across the finish line:

  • Follow the TypeScript, JavaScript, CSS and React coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

Please be patient and we will get back to you as soon as we can.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the module-based WASM import with a URL-based approach to improve bundle size and build speed. Instead of importing the WASM file as a module, it now fetches the oniguruma WASM file directly from unpkg.com CDN.

  • Removes the module import of vscode-oniguruma/release/onig.wasm
  • Uses a direct CDN URL to fetch the WASM file at runtime
  • Simplifies the URL handling logic by removing conditional checks for different path formats

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

onigurumaUrl = onigurumaPath.default;
}
const onigurumaPath = 'https://unpkg.com/vscode-oniguruma@2.0.1/release/onig.wasm';
const url = new URL(onigurumaPath);
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a URL object from an absolute URL string is unnecessary overhead. The fetch() API accepts strings directly, so you can pass 'onigurumaPath' to fetch without wrapping it in a URL object first.

Copilot uses AI. Check for mistakes.
if (typeof onigurumaPath !== 'string' && onigurumaPath.default) {
onigurumaUrl = onigurumaPath.default;
}
const onigurumaPath = 'https://unpkg.com/vscode-oniguruma@2.0.1/release/onig.wasm';
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a hardcoded external CDN URL (unpkg.com) may cause reliability issues in environments with restricted network access, offline scenarios, or if the CDN is unavailable. Consider making this URL configurable through an environment variable or configuration file, or bundling the WASM file as a fallback option.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants