Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions packages/libro-cofine-textmate/src/monaco-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { Module } from '@difizen/libro-common/app';
import * as oniguruma from 'vscode-oniguruma';
import * as onig from 'vscode-oniguruma/release/onig.wasm';

import {
isBasicWasmSupported,
Expand All @@ -17,14 +16,10 @@ import { TextmateRegistry } from './textmate-registry.js';
import { TextmateThemeContribution } from './textmate-theme-contribution.js';

export async function fetchOniguruma(): Promise<ArrayBuffer | Response> {
// const onigurumaPath = 'https://unpkg.com/vscode-oniguruma@2.0.1/release/onig.wasm'; // webpack doing its magic here
const onigurumaPath = onig;
let onigurumaUrl = onigurumaPath;
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.
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.

const response = await fetch(onigurumaUrl);
const response = await fetch(url);
const contentType = response.headers.get('content-type');
if (contentType === 'application/wasm') {
return response;
Expand Down
Loading