@danielx/civet 0.1.1 → 0.2.2
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/README.md +9 -2
- package/dist/browser.js +725 -425
- package/dist/browser.js.map +2 -2
- package/dist/civet +11 -11
- package/dist/cli.js.map +3 -3
- package/dist/main.js +725 -425
- package/package.json +4 -2
- package/register.js +12 -0
- package/register.mjs +40 -0
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "CoffeeScript style syntax for TypeScript",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"civet": "dist/civet"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"dist/"
|
|
10
|
+
"dist/",
|
|
11
|
+
"register.js",
|
|
12
|
+
"register.mjs"
|
|
11
13
|
],
|
|
12
14
|
"scripts": {
|
|
13
15
|
"build": "bash ./build/build.sh",
|
package/register.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
if (require.extensions) {
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const { compile } = require("./");
|
|
4
|
+
|
|
5
|
+
require.extensions[".civet"] = function (module, filename) {
|
|
6
|
+
const js = compile(fs.readFileSync(filename, 'utf8'), {
|
|
7
|
+
js: true
|
|
8
|
+
});
|
|
9
|
+
module._compile(js, filename);
|
|
10
|
+
return;
|
|
11
|
+
};
|
|
12
|
+
}
|
package/register.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { pathToFileURL } from 'url';
|
|
3
|
+
|
|
4
|
+
import { compile } from "./dist/main.js";
|
|
5
|
+
|
|
6
|
+
const baseURL = pathToFileURL(process.cwd() + '/').href;
|
|
7
|
+
|
|
8
|
+
const extensionsRegex = /\.civet$/;
|
|
9
|
+
|
|
10
|
+
export async function resolve(specifier, context, defaultResolve) {
|
|
11
|
+
const { parentURL = baseURL } = context;
|
|
12
|
+
|
|
13
|
+
if (extensionsRegex.test(specifier)) {
|
|
14
|
+
return {
|
|
15
|
+
format: "civet",
|
|
16
|
+
url: new URL(specifier, parentURL).href,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Let Node.js handle all other specifiers.
|
|
21
|
+
return defaultResolve(specifier, context, defaultResolve);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function load(url, context, defaultLoad) {
|
|
25
|
+
if (extensionsRegex.test(url)) {
|
|
26
|
+
const { source: rawSource } = await defaultLoad(url, { format: "civet" });
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
format: "module",
|
|
30
|
+
source: compile(rawSource.toString(), { js: true }),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Let Node.js handle all other URLs.
|
|
35
|
+
return defaultLoad(url, context, defaultLoad);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Also transform CommonJS files.
|
|
39
|
+
const require = createRequire(import.meta.url);
|
|
40
|
+
require("./register.js")
|