Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"contributors": [
"Daniel Swann (https://github.com/danswann)",
"Longboyy",
"Helloman892"
"Helloman892",
"Sarah Klocke (https://sarahisweird.dev/)"
],
"main": "index.js",
"repository": {
Expand Down
9 changes: 7 additions & 2 deletions src/processScript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import rollupPluginJSON from "@rollup/plugin-json"
import rollupPluginNodeResolve from "@rollup/plugin-node-resolve"
import type { LaxPartial } from "@samual/lib"
import { assert } from "@samual/lib/assert"
import { relative as getRelativePath } from "path"
import { relative as getRelativePath, sep as pathSeparator } from "path"
import prettier from "prettier"
import { rollup } from "rollup"
import { supportedExtensions as extensions } from "../constants"
Expand All @@ -47,6 +47,11 @@ export { postprocess } from "./postprocess"
export { preprocess } from "./preprocess"
export { transform } from "./transform"

function isPath(str: string): boolean {
if (pathSeparator == `/`) return str.startsWith(`/`);
return /^[A-Z]:\\/.test(str);
}

export type ProcessOptions = LaxPartial<{
/** whether to minify the given code */ minify: boolean
/** 11 a-z 0-9 characters */ uniqueId: string
Expand Down Expand Up @@ -260,7 +265,7 @@ export async function processScript(code: string, {
{
name: `hackmud-script-manager`,
async transform(code, id) {
if (id.startsWith(`/`) && !id.includes(`/node_modules/`))
if (isPath(id) && !id.includes(`${pathSeparator}node_modules${pathSeparator}`))
return (await preprocess(code, { uniqueId })).code

let program!: NodePath<Program>
Expand Down
Loading