@danielx/civet 0.9.2 → 0.9.4
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/CHANGELOG.md +18 -0
- package/dist/browser.js +898 -493
- package/dist/civet +1 -1
- package/dist/esm.mjs +11 -5
- package/dist/main.js +1167 -625
- package/dist/main.mjs +1167 -625
- package/dist/node-worker.mjs +7 -2
- package/dist/types.d.ts +7 -6
- package/dist/unplugin/unplugin.js +5 -15
- package/dist/unplugin/unplugin.mjs +5 -15
- package/package.json +2 -2
package/dist/node-worker.mjs
CHANGED
|
@@ -20,9 +20,14 @@ try {
|
|
|
20
20
|
throw `Unknown operation: ${op}`;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
return parentPort.postMessage({ id, result });
|
|
23
|
+
return parentPort.postMessage({ id, result, errors: args[1]?.errors });
|
|
24
24
|
} catch (error) {
|
|
25
|
-
|
|
25
|
+
console.log(`Civet worker failed to compile:`, error);
|
|
26
|
+
return parentPort.postMessage({ id, error: {
|
|
27
|
+
type: error.constructor.name,
|
|
28
|
+
name: error.name,
|
|
29
|
+
message: error.message
|
|
30
|
+
} });
|
|
26
31
|
}
|
|
27
32
|
});
|
|
28
33
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -62,14 +62,15 @@ declare module "@danielx/civet" {
|
|
|
62
62
|
|
|
63
63
|
export type SourceMapping = [number] | [number, number, number, number]
|
|
64
64
|
|
|
65
|
-
export
|
|
65
|
+
export class SourceMap {
|
|
66
|
+
constructor(source: string)
|
|
66
67
|
updateSourceMap?(outputStr: string, inputPos: number): void
|
|
67
68
|
json(srcFileName: string, outFileName: string): unknown
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
source: string
|
|
70
|
+
lines: SourceMapping[][]
|
|
71
|
+
/** @deprecated */
|
|
72
|
+
data: { lines: SourceMapping[][] }
|
|
71
73
|
}
|
|
72
|
-
export function SourceMap(source: string): SourceMap
|
|
73
74
|
|
|
74
75
|
// TODO: Import ParseError class from Hera
|
|
75
76
|
export type ParseError = {
|
|
@@ -121,7 +122,7 @@ declare module "@danielx/civet" {
|
|
|
121
122
|
sourcemap: {
|
|
122
123
|
locationTable(input: string): number[]
|
|
123
124
|
lookupLineColumn(table: number[], pos: number): [number, number]
|
|
124
|
-
SourceMap
|
|
125
|
+
SourceMap: typeof SourceMap
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -290,7 +290,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
290
290
|
if (!file) return diagnostic;
|
|
291
291
|
const sourceMap = sourceMaps.get(file.fileName);
|
|
292
292
|
if (!sourceMap) return diagnostic;
|
|
293
|
-
const sourcemapLines = sourceMap.data.lines;
|
|
293
|
+
const sourcemapLines = sourceMap.lines ?? sourceMap.data.lines;
|
|
294
294
|
const range = (0, import_ts_diagnostic.remapRange)(
|
|
295
295
|
{
|
|
296
296
|
start: diagnostic.start || 0,
|
|
@@ -369,16 +369,6 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
369
369
|
compilerOptions.outDir ?? process.cwd(),
|
|
370
370
|
filePath
|
|
371
371
|
);
|
|
372
|
-
if (meta.framework === "esbuild") {
|
|
373
|
-
fs.mkdirSync(
|
|
374
|
-
import_path.default.dirname(
|
|
375
|
-
import_path.default.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
376
|
-
),
|
|
377
|
-
{
|
|
378
|
-
recursive: true
|
|
379
|
-
}
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
372
|
return this.emitFile({
|
|
383
373
|
source: content,
|
|
384
374
|
fileName: pathFromDistDir,
|
|
@@ -402,9 +392,6 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
402
392
|
id = aliasResolver(id);
|
|
403
393
|
}
|
|
404
394
|
if (/\0/.test(id)) return null;
|
|
405
|
-
if (plugin.__virtualModulePrefix && importer?.startsWith(plugin.__virtualModulePrefix)) {
|
|
406
|
-
importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
407
|
-
}
|
|
408
395
|
let postfix;
|
|
409
396
|
({ id, postfix } = cleanCivetId(id));
|
|
410
397
|
let ref2;
|
|
@@ -475,7 +462,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
475
462
|
...civetOptions,
|
|
476
463
|
ast: true
|
|
477
464
|
});
|
|
478
|
-
const civetSourceMap =
|
|
465
|
+
const civetSourceMap = new import_civet.SourceMap(rawCivetSource);
|
|
479
466
|
if (ts === "civet") {
|
|
480
467
|
compiled = await import_civet.default.generate(ast, {
|
|
481
468
|
...civetOptions,
|
|
@@ -608,6 +595,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
608
595
|
},
|
|
609
596
|
webpack(compiler) {
|
|
610
597
|
if (implicitExtension) {
|
|
598
|
+
compiler.options ??= {};
|
|
599
|
+
compiler.options.resolve ??= {};
|
|
600
|
+
compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
|
|
611
601
|
compiler.options.resolve.extensions.unshift(".civet");
|
|
612
602
|
}
|
|
613
603
|
return aliasResolver = (id) => {
|
|
@@ -258,7 +258,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
258
258
|
if (!file) return diagnostic;
|
|
259
259
|
const sourceMap = sourceMaps.get(file.fileName);
|
|
260
260
|
if (!sourceMap) return diagnostic;
|
|
261
|
-
const sourcemapLines = sourceMap.data.lines;
|
|
261
|
+
const sourcemapLines = sourceMap.lines ?? sourceMap.data.lines;
|
|
262
262
|
const range = remapRange(
|
|
263
263
|
{
|
|
264
264
|
start: diagnostic.start || 0,
|
|
@@ -337,16 +337,6 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
337
337
|
compilerOptions.outDir ?? process.cwd(),
|
|
338
338
|
filePath
|
|
339
339
|
);
|
|
340
|
-
if (meta.framework === "esbuild") {
|
|
341
|
-
fs.mkdirSync(
|
|
342
|
-
path.dirname(
|
|
343
|
-
path.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
344
|
-
),
|
|
345
|
-
{
|
|
346
|
-
recursive: true
|
|
347
|
-
}
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
340
|
return this.emitFile({
|
|
351
341
|
source: content,
|
|
352
342
|
fileName: pathFromDistDir,
|
|
@@ -370,9 +360,6 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
370
360
|
id = aliasResolver(id);
|
|
371
361
|
}
|
|
372
362
|
if (/\0/.test(id)) return null;
|
|
373
|
-
if (plugin.__virtualModulePrefix && importer?.startsWith(plugin.__virtualModulePrefix)) {
|
|
374
|
-
importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
375
|
-
}
|
|
376
363
|
let postfix;
|
|
377
364
|
({ id, postfix } = cleanCivetId(id));
|
|
378
365
|
let ref2;
|
|
@@ -443,7 +430,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
443
430
|
...civetOptions,
|
|
444
431
|
ast: true
|
|
445
432
|
});
|
|
446
|
-
const civetSourceMap = SourceMap(rawCivetSource);
|
|
433
|
+
const civetSourceMap = new SourceMap(rawCivetSource);
|
|
447
434
|
if (ts === "civet") {
|
|
448
435
|
compiled = await civet.generate(ast, {
|
|
449
436
|
...civetOptions,
|
|
@@ -576,6 +563,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
576
563
|
},
|
|
577
564
|
webpack(compiler) {
|
|
578
565
|
if (implicitExtension) {
|
|
566
|
+
compiler.options ??= {};
|
|
567
|
+
compiler.options.resolve ??= {};
|
|
568
|
+
compiler.options.resolve.extensions ??= ["", ".js", ".json", ".wasm"];
|
|
579
569
|
compiler.options.resolve.extensions.unshift(".civet");
|
|
580
570
|
}
|
|
581
571
|
return aliasResolver = (id) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.4",
|
|
5
5
|
"description": "CoffeeScript style syntax for TypeScript",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/main.mjs",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"unplugin": "^2.1.0"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@danielx/civet": "0.9.
|
|
98
|
+
"@danielx/civet": "0.9.2",
|
|
99
99
|
"@danielx/hera": "^0.8.16",
|
|
100
100
|
"@prettier/sync": "^0.5.2",
|
|
101
101
|
"@types/assert": "^1.5.6",
|