Unknown file extension ".zx" #1104
Unanswered
lukakostic
asked this question in
Help needed
Replies: 1 comment
-
I'm afraid, this part of logic belongs to nodejs: // loader.mjs
import path from 'node:path'
const exts = new Set(['.zx'])
export async function resolve(specifier, context, nextResolve) {
const ext = path.extname(specifier)
if (!exts.has(ext)) { return nextResolve(specifier) }
const { url } = await nextResolve(specifier)
return {
format: 'zx',
shortCircuit: true,
url,
}
}
export async function load(url, context, nextLoad) {
if (context.format !== 'zx') { return nextLoad(url) }
return {
format: 'module',
shortCircuit: true,
source: '' + (await nextLoad(url, { ...context, format: 'module' })).source,
}
} NODE_OPTIONS="--loader=./loader.mjs" ./my-script.zx |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Script:
Ran with:
$ ./my-script.zx
Results in:
Why does it care about file extensions on linux?
Why cant i end my script file with .zx ?
If im running with the hashbang zx , obviously its a valid zx script (javascript) which im trying to run, so why check extension?
Its not like i can run typescript too so it needs to know js vs ts ?
Beta Was this translation helpful? Give feedback.
All reactions