wurzel 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/index.js
CHANGED
|
@@ -35,13 +35,14 @@ const md5 = ({ content }/*: { content: string }*/) => {
|
|
|
35
35
|
|
|
36
36
|
const defaultResolveImportPath/*: TResolveImportPathFunc*/ = async ({ importer, specifier }) => {
|
|
37
37
|
const parentUrl = pathToFileURL(importer);
|
|
38
|
+
// eslint-disable-next-line no-useless-assignment
|
|
38
39
|
let resolvedUrl/*: string | undefined*/ = undefined;
|
|
39
40
|
|
|
40
41
|
try {
|
|
41
42
|
resolvedUrl = resolveImport(specifier, parentUrl.toString());
|
|
42
43
|
} catch (error) {
|
|
43
44
|
return {
|
|
44
|
-
error: error/*
|
|
45
|
+
error: error /*as Error*/
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -82,6 +83,7 @@ const expressRouter = ({
|
|
|
82
83
|
maxTranspileCacheSize?: number,
|
|
83
84
|
|
|
84
85
|
resolveImportPath?: TResolveImportPathFunc
|
|
86
|
+
// eslint-disable-next-line complexity
|
|
85
87
|
}*/) => {
|
|
86
88
|
|
|
87
89
|
const router = express.Router();
|
|
@@ -119,6 +121,7 @@ const expressRouter = ({
|
|
|
119
121
|
};
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
// eslint-disable-next-line no-useless-assignment
|
|
122
125
|
let transpiled/*: string | undefined*/ = undefined;
|
|
123
126
|
|
|
124
127
|
try {
|
|
@@ -126,7 +129,7 @@ const expressRouter = ({
|
|
|
126
129
|
transpiled = result.transpiledCode;
|
|
127
130
|
} catch (ex) {
|
|
128
131
|
return {
|
|
129
|
-
error: ex/*
|
|
132
|
+
error: ex /*as Error*/,
|
|
130
133
|
};
|
|
131
134
|
}
|
|
132
135
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
expressRouter as wurzelExpressRouter,
|
|
3
|
+
defaultResolveImportPath,
|
|
4
|
+
/*type TResolveImportPathFunc
|
|
5
|
+
*/} from "../../lib/index.js";
|
|
6
|
+
import nodePath from "node:path";
|
|
7
|
+
import { resolve } from "esm-resource";
|
|
8
|
+
import express from "express";
|
|
9
|
+
|
|
10
|
+
const relativePath = ({ filepath }/*: { filepath: string }*/) => {
|
|
11
|
+
return nodePath.resolve(resolve({ importMeta: import.meta, filepath }));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const baseFolder = relativePath({ filepath: "./frontend" });
|
|
15
|
+
|
|
16
|
+
const resolveImportPath/*: TResolveImportPathFunc*/ = async ({ importer, specifier }) => {
|
|
17
|
+
if (specifier === "vue") {
|
|
18
|
+
return {
|
|
19
|
+
error: undefined,
|
|
20
|
+
// this is only an example, it is neither installed nor used in this sample
|
|
21
|
+
filePath: relativePath({ filepath: "../node_modules/vue/dist/vue.esm-browser.js" })
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return defaultResolveImportPath({ importer, specifier });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const app = express();
|
|
29
|
+
|
|
30
|
+
app.use("/", wurzelExpressRouter({
|
|
31
|
+
express,
|
|
32
|
+
baseFolder,
|
|
33
|
+
fileEndings: [".ts", ".js", ".mjs"],
|
|
34
|
+
resolveImportPath
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
const port = 8080;
|
|
38
|
+
|
|
39
|
+
app.listen(port, () => {
|
|
40
|
+
console.log(`listening on :${port}`);
|
|
41
|
+
});
|
package/package.json
CHANGED
|
@@ -1,42 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
+
"version": "0.0.10",
|
|
2
3
|
"name": "wurzel",
|
|
3
|
-
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"description": "A tool to serve script files from different directories",
|
|
5
6
|
"files": [
|
|
6
7
|
"dist"
|
|
7
8
|
],
|
|
8
9
|
"main": "dist/lib/index.js",
|
|
9
10
|
"dependencies": {
|
|
10
|
-
"commentscript": "^0.0.
|
|
11
|
-
"es6-debug-server": "^0.0.
|
|
12
|
-
"esm-resource": "^0.0.
|
|
13
|
-
"express": "^4.19.2",
|
|
11
|
+
"commentscript": "^0.0.10",
|
|
12
|
+
"es6-debug-server": "^0.0.9",
|
|
13
|
+
"esm-resource": "^0.0.3",
|
|
14
14
|
"import-meta-resolve": "^4.0.0",
|
|
15
15
|
"lru-cache": "^10.2.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@eslint/js": "^
|
|
18
|
+
"@eslint/js": "^10.0.1",
|
|
19
|
+
"@k13engineering/releasetool": "^0.0.5",
|
|
19
20
|
"@types/express": "^4.17.21",
|
|
20
21
|
"@types/node": "^20.12.7",
|
|
21
|
-
"deno-node": "^0.0.
|
|
22
|
-
"
|
|
22
|
+
"deno-node": "^0.0.12",
|
|
23
|
+
"express": "^5.2.1",
|
|
24
|
+
"npm-check-updates": "^20.0.2",
|
|
25
|
+
"typescript-eslint": "^8.58.2"
|
|
23
26
|
},
|
|
24
27
|
"bin": {
|
|
25
28
|
"wurzel": "dist/bin/wurzel.js"
|
|
26
29
|
},
|
|
27
30
|
"scripts": {
|
|
28
|
-
"build": "rm -rf dist/ && deno-node-build --root . --out dist/ --entry lib/index.ts --entry bin/wurzel.ts",
|
|
31
|
+
"build": "rm -rf dist/ && deno-node-build --root . --out dist/ --entry lib/index.ts --entry bin/wurzel.ts --entry samples/express/main.ts && cp -r samples/express/frontend dist/samples/express/",
|
|
29
32
|
"lint": "eslint .",
|
|
30
|
-
"test": "true"
|
|
33
|
+
"test": "true",
|
|
34
|
+
"type-check": "tsc --noEmit",
|
|
35
|
+
"update-deps": "npm-check-updates -u"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
31
39
|
},
|
|
32
40
|
"author": "Simon Kadisch",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
"license": "LGPL-2.1",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/k13-engineering/wurzel.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/k13-engineering/wurzel/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/k13-engineering/wurzel#readme"
|
|
42
50
|
}
|