elegance-js 3.0.3 → 3.0.5
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/bin/export.js +0 -0
- package/bin/template_project/elegance.config.ts +6 -0
- package/bin/template_project/package.json +6 -0
- package/bin/template_project/pages/404.tsx +3 -0
- package/bin/template_project/pages/layout.tsx +5 -0
- package/bin/template_project/pages/metadata.tsx +5 -0
- package/bin/template_project/pages/page.tsx +11 -0
- package/bin/template_project/public/index.css +1 -0
- package/dist/processing/oxc.d.ts.map +1 -1
- package/dist/processing/oxc.js +60 -1
- package/package.json +3 -2
package/bin/export.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* You can put your styles here! */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxc.d.ts","sourceRoot":"","sources":["../../src/processing/oxc.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,IAAI;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACvB;AAwGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CActE;AAyFD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAuBhE;
|
|
1
|
+
{"version":3,"file":"oxc.d.ts","sourceRoot":"","sources":["../../src/processing/oxc.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,IAAI;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACvB;AAwGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CActE;AAyFD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAuBhE;AAomBD,wBAAgB,eAAe,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACjB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAQ/C;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA0BzD;AAwSD,wBAAgB,oBAAoB,CAChC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACjB,MAAM,CAiDR;AAgHD,wBAAgB,8BAA8B,CAC1C,aAAa,EAAI,MAAM,EACvB,eAAe,EAAE,MAAM,EAAE,GAC1B,IAAI,CAEN;AAED,wBAAgB,uBAAuB,CACnC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,EACrB,eAAe,EAAE,MAAM,EAAE,GAC1B,MAAM,CA0CR"}
|
package/dist/processing/oxc.js
CHANGED
|
@@ -431,6 +431,64 @@ If that is not the case, remove the reference that cause their inclusion.`,
|
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
+
{
|
|
435
|
+
const programComments = ast.comments ?? [];
|
|
436
|
+
const allowedImports = /* @__PURE__ */ new Set();
|
|
437
|
+
for (const comment of programComments) {
|
|
438
|
+
if (comment.type !== "Line") continue;
|
|
439
|
+
if (comment.value.trim() !== "!allow-bundling") continue;
|
|
440
|
+
const afterComment = comment.end;
|
|
441
|
+
const annotatedNode = body.find((n) => n.start >= afterComment);
|
|
442
|
+
if (annotatedNode && annotatedNode.type === "ImportDeclaration") {
|
|
443
|
+
allowedImports.add(annotatedNode);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const violations = [];
|
|
447
|
+
for (const node of body) {
|
|
448
|
+
if (node.type !== "ImportDeclaration") continue;
|
|
449
|
+
const specs = node.specifiers ?? [];
|
|
450
|
+
if (specs.length === 0) {
|
|
451
|
+
if (!allowedImports.has(node)) {
|
|
452
|
+
violations.push({ importNode: node });
|
|
453
|
+
}
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
const hasReachable = specs.some((s) => reachable.has(s.local.name));
|
|
457
|
+
if (!hasReachable) continue;
|
|
458
|
+
if (!allowedImports.has(node)) {
|
|
459
|
+
const reachableSpec = specs.find((s) => reachable.has(s.local.name));
|
|
460
|
+
violations.push({ importNode: node, exampleSpec: reachableSpec.local.name });
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (violations.length > 0) {
|
|
464
|
+
const list = violations.map(({ importNode, exampleSpec }) => {
|
|
465
|
+
let chain = "";
|
|
466
|
+
if (exampleSpec) {
|
|
467
|
+
chain = formatReachabilityChain(source, filePath, exampleSpec, reachableFrom);
|
|
468
|
+
} else {
|
|
469
|
+
const { line, col } = offsetToLineCol(source, importNode.start);
|
|
470
|
+
const sourceLine = getSourceLine(source, importNode.start);
|
|
471
|
+
const pipe = " | ";
|
|
472
|
+
const caretLine = `${pipe}${" ".repeat(col - 1)}^`;
|
|
473
|
+
chain = ` at import "${importNode.source.value}" (side-effect import) (${filePath}:${line}:${col})
|
|
474
|
+
${pipe}${sourceLine}
|
|
475
|
+
${caretLine}`;
|
|
476
|
+
}
|
|
477
|
+
return ` \u2022 Import from "${importNode.source.value}"
|
|
478
|
+
${chain}`;
|
|
479
|
+
}).join("\n\n");
|
|
480
|
+
throw richError({
|
|
481
|
+
title: "Missing allow\u2011bundling directive",
|
|
482
|
+
cause: `\\The following imports are reachable and will be bundled, but they are not marked with //!allow-bundling:
|
|
483
|
+
|
|
484
|
+
${list}
|
|
485
|
+
|
|
486
|
+
Every import that survives into the client bundle must be explicitly allowed.`,
|
|
487
|
+
hint: `\\Add a line comment //!allow-bundling immediately above each import statement.`,
|
|
488
|
+
doShowStack: false
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
434
492
|
const removalEdits = [];
|
|
435
493
|
function trailingEnd(end) {
|
|
436
494
|
return end < source.length && source[end] === "\n" ? end + 1 : end;
|
|
@@ -856,7 +914,8 @@ function computeSyntheticBundleStaticParts(preClientCode, filePath, layoutCacheK
|
|
|
856
914
|
}
|
|
857
915
|
const replaced = applyServerActionCallReplacements(preClientCode, ast);
|
|
858
916
|
const withoutDefault = defaultStart >= 0 ? replaced.slice(0, defaultStart) + replaced.slice(defaultEnd) : replaced;
|
|
859
|
-
const layoutImports = layoutCacheKeys.map((lk, i) =>
|
|
917
|
+
const layoutImports = layoutCacheKeys.map((lk, i) => `//!allow-bundling
|
|
918
|
+
import { default as __l${i} } from "/chunks/${lk}.client.mjs";`).join("\n");
|
|
860
919
|
const layoutCalls = layoutCacheKeys.map((_, i) => ` const _l${i} = __l${i}();`).join("\n");
|
|
861
920
|
const regionsSpread = layoutCacheKeys.map((_, i) => `..._l${i}.regions`).join(", ");
|
|
862
921
|
const handlersSpread = layoutCacheKeys.map((_, i) => `..._l${i}.handlers`).join(", ");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elegance-js",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/user-utils.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"export": "./bin/export.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"bin"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"lint": "oxlint ./src --fix -D unused-variable -D unused-import",
|