@@ -26,7 +26,7 @@ import rollupPluginJSON from "@rollup/plugin-json"
2626import rollupPluginNodeResolve from "@rollup/plugin-node-resolve"
2727import type { LaxPartial } from "@samual/lib"
2828import { assert } from "@samual/lib/assert"
29- import { relative as getRelativePath } from "path"
29+ import { relative as getRelativePath , sep as pathSeparator } from "path"
3030import prettier from "prettier"
3131import { rollup } from "rollup"
3232import { supportedExtensions as extensions } from "../constants"
@@ -47,6 +47,11 @@ export { postprocess } from "./postprocess"
4747export { preprocess } from "./preprocess"
4848export { transform } from "./transform"
4949
50+ function isPath ( str : string ) : boolean {
51+ if ( pathSeparator == `/` ) return str . startsWith ( `/` ) ;
52+ return / ^ [ A - Z ] : \\ / . test ( str ) ;
53+ }
54+
5055export type ProcessOptions = LaxPartial < {
5156 /** whether to minify the given code */ minify : boolean
5257 /** 11 a-z 0-9 characters */ uniqueId : string
@@ -260,7 +265,7 @@ export async function processScript(code: string, {
260265 {
261266 name : `hackmud-script-manager` ,
262267 async transform ( code , id ) {
263- if ( id . startsWith ( `/` ) && ! id . includes ( `/ node_modules/ ` ) )
268+ if ( isPath ( id ) && ! id . includes ( `${ pathSeparator } node_modules${ pathSeparator } ` ) )
264269 return ( await preprocess ( code , { uniqueId } ) ) . code
265270
266271 let program ! : NodePath < Program >
0 commit comments