mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-18 06:17:23 +08:00
c6cfb4f53f
* build: bump workers compatibility date * build: remove implemented shim * build: use native createRequire for node:module shim * fix: resolve process through the node:module shim this fixes youtubei.js on workers * style: fix oxlint * refactor: ditch vm2 for ichunqiu * build: bundle data files header-generator in workers
13 lines
721 B
TypeScript
13 lines
721 B
TypeScript
// oxlint-disable unicorn/prefer-node-protocol -- 'node:module' is aliased to this file, the bare specifier reaches the runtime module
|
|
// Shim for node:module in Cloudflare Workers
|
|
import { createRequire as nativeCreateRequire } from 'module';
|
|
|
|
// Rolldown calls createRequire(import.meta.url), and import.meta.url is undefined in Workers ESM.
|
|
// The native createRequire rejects undefined, so default the path and delegate to the native module.
|
|
export const createRequire = (filename?: string | URL) => {
|
|
const require = nativeCreateRequire(filename ?? 'file:///worker/index.mjs');
|
|
return (id: string) => (id === 'process' || id === 'node:process' ? process : require(id));
|
|
};
|
|
|
|
export default { createRequire };
|