mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Fix minified build
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import * as valuescript from 'valuescript';
|
||||
import hasExtension from '../helpers/hasExtension';
|
||||
import nil from '../helpers/nil';
|
||||
import { initVslib } from './index';
|
||||
|
||||
@@ -35,13 +34,30 @@ async function main() {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function makeLookupFile(files: Record<string, string | nil>) {
|
||||
return (filePath: string) => {
|
||||
let content = files[filePath];
|
||||
|
||||
if (content === undefined && !hasExtension(filePath)) {
|
||||
content = files[`${filePath}.ts`] ?? files[`${filePath}.js`];
|
||||
}
|
||||
|
||||
if (content === undefined) {
|
||||
throw new Error('Not found');
|
||||
}
|
||||
|
||||
return content;
|
||||
};
|
||||
}
|
||||
|
||||
function hasExtension(path: string) {
|
||||
return path.split('/').at(-1)?.includes('.') ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
const workerScript = [
|
||||
initVslib.toString(),
|
||||
makeLookupFile.toString(),
|
||||
hasExtension.toString(),
|
||||
'const nil = undefined;',
|
||||
`(${main.toString()})()`,
|
||||
].join('\n\n');
|
||||
|
||||
@@ -140,19 +156,3 @@ export default class VslibPool {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function makeLookupFile(files: Record<string, string | nil>) {
|
||||
return (filePath: string) => {
|
||||
let content = files[filePath];
|
||||
|
||||
if (content === nil && !hasExtension(filePath)) {
|
||||
content = files[`${filePath}.ts`] ?? files[`${filePath}.js`];
|
||||
}
|
||||
|
||||
if (content === nil) {
|
||||
throw new Error('Not found');
|
||||
}
|
||||
|
||||
return content;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user