From af6b43ab9a24ab2c0e2d30b63e4418f91f7edfa5 Mon Sep 17 00:00:00 2001 From: Kevin Deng Date: Fri, 2 Jan 2026 23:41:21 +0800 Subject: [PATCH] refactor: remove `HELPERS_ID_RE` --- src/helper.ts | 1 - src/index.ts | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/helper.ts b/src/helper.ts index 6711145..6f509ee 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -1,7 +1,6 @@ import type { TargetEnv } from './options' export const HELPERS_ID: string = '\0wasm-helpers.js' -export const HELPERS_ID_RE: RegExp = /\0wasm-helpers\.js$/ const nodeFilePath = ` const { readFile } = process.getBuiltinModule('fs/promises') diff --git a/src/index.ts b/src/index.ts index 211bd84..3c39b56 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,12 +2,11 @@ import { Buffer } from 'node:buffer' import { createHash } from 'node:crypto' import { readFile } from 'node:fs/promises' import path from 'node:path' -import { id, include, or } from 'rolldown/filter' +import { exactRegex, id, include, or } from 'rolldown/filter' import { codegenSimpleObject, getHelpersModule, HELPERS_ID, - HELPERS_ID_RE, type SimpleObject, } from './helper' import { parseWasm, type WasmInfo } from './wasm-parser' @@ -59,7 +58,9 @@ export function wasm(options: Options = {}): Plugin { resolveId: { filter: [ - include(or(id(HELPERS_ID_RE), id(/\.wasm$/, { cleanUrl: true }))), + include( + or(id(exactRegex(HELPERS_ID)), id(/\.wasm$/, { cleanUrl: true })), + ), ], async handler(id, ...args) { @@ -81,7 +82,9 @@ export function wasm(options: Options = {}): Plugin { load: { filter: [ - include(or(id(HELPERS_ID_RE), id(/\.wasm$/, { cleanUrl: true }))), + include( + or(id(exactRegex(HELPERS_ID)), id(/\.wasm$/, { cleanUrl: true })), + ), ], async handler(id) { -- 2.51.2