elegance-js 1.11.18 → 1.11.19
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/page_compiler.mjs +40 -36
- package/package.json +1 -1
package/dist/page_compiler.mjs
CHANGED
|
@@ -691,26 +691,30 @@ var buildPage = async (DIST_DIR2, directory, filePath, name) => {
|
|
|
691
691
|
entryPoints: [filePath],
|
|
692
692
|
outfile: filePath,
|
|
693
693
|
allowOverwrite: true,
|
|
694
|
-
bundle:
|
|
695
|
-
format: "
|
|
694
|
+
bundle: true,
|
|
695
|
+
format: "cjs",
|
|
696
696
|
plugins: [
|
|
697
697
|
{
|
|
698
|
-
name: "wrap-
|
|
698
|
+
name: "wrap-cjs",
|
|
699
699
|
setup(build2) {
|
|
700
700
|
build2.onEnd(async () => {
|
|
701
701
|
const fs2 = await import("fs/promises");
|
|
702
702
|
const code = await fs2.readFile(build2.initialOptions.outfile, "utf8");
|
|
703
|
-
const wrapped = `export
|
|
703
|
+
const wrapped = `export function construct() {
|
|
704
704
|
const exports = {};
|
|
705
|
-
|
|
705
|
+
const module = { exports };
|
|
706
|
+
(function(exports, module) {
|
|
707
|
+
${code.split("\n").map((l) => " " + l).join("\n")}
|
|
708
|
+
})(exports, module);
|
|
706
709
|
|
|
707
|
-
return exports;
|
|
710
|
+
return module.exports;
|
|
708
711
|
}
|
|
709
712
|
`;
|
|
710
713
|
await fs2.writeFile(build2.initialOptions.outfile, wrapped);
|
|
711
714
|
});
|
|
712
715
|
}
|
|
713
|
-
}
|
|
716
|
+
},
|
|
717
|
+
externalPackagesPlugin
|
|
714
718
|
]
|
|
715
719
|
});
|
|
716
720
|
return false;
|
|
@@ -754,6 +758,35 @@ var buildPage = async (DIST_DIR2, directory, filePath, name) => {
|
|
|
754
758
|
);
|
|
755
759
|
return sendHardReloadInstruction === true;
|
|
756
760
|
};
|
|
761
|
+
var recursionFlag = Symbol("external-node-modules-recursion");
|
|
762
|
+
var externalPackagesPlugin = {
|
|
763
|
+
name: "external-packages",
|
|
764
|
+
setup(build2) {
|
|
765
|
+
build2.onResolve({ filter: /^[^./]/ }, async (args) => {
|
|
766
|
+
if (args.pluginData?.[recursionFlag]) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
const result = await build2.resolve(args.path, {
|
|
770
|
+
resolveDir: args.resolveDir,
|
|
771
|
+
kind: args.kind,
|
|
772
|
+
importer: args.importer,
|
|
773
|
+
pluginData: { [recursionFlag]: true }
|
|
774
|
+
});
|
|
775
|
+
if (result.errors.length > 0 || result.external || !result.path) {
|
|
776
|
+
return { path: args.path, external: true };
|
|
777
|
+
}
|
|
778
|
+
const nodeModulesIndex = result.path.indexOf("node_modules");
|
|
779
|
+
if (nodeModulesIndex === -1) {
|
|
780
|
+
return result;
|
|
781
|
+
}
|
|
782
|
+
const isNested = result.path.includes("node_modules", nodeModulesIndex + 14);
|
|
783
|
+
if (isNested) {
|
|
784
|
+
return { path: args.path, external: true };
|
|
785
|
+
}
|
|
786
|
+
return { path: args.path, external: true };
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
};
|
|
757
790
|
var build = async () => {
|
|
758
791
|
if (options.quiet === true) {
|
|
759
792
|
console.log = function() {
|
|
@@ -788,36 +821,7 @@ var build = async () => {
|
|
|
788
821
|
}
|
|
789
822
|
const projectFiles = getProjectFiles(options.pagesDirectory);
|
|
790
823
|
const start = performance.now();
|
|
791
|
-
const recursionFlag = Symbol("external-node-modules-recursion");
|
|
792
824
|
{
|
|
793
|
-
const externalPackagesPlugin = {
|
|
794
|
-
name: "external-packages",
|
|
795
|
-
setup(build2) {
|
|
796
|
-
build2.onResolve({ filter: /^[^./]/ }, async (args) => {
|
|
797
|
-
if (args.pluginData?.[recursionFlag]) {
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
800
|
-
const result = await build2.resolve(args.path, {
|
|
801
|
-
resolveDir: args.resolveDir,
|
|
802
|
-
kind: args.kind,
|
|
803
|
-
importer: args.importer,
|
|
804
|
-
pluginData: { [recursionFlag]: true }
|
|
805
|
-
});
|
|
806
|
-
if (result.errors.length > 0 || result.external || !result.path) {
|
|
807
|
-
return { path: args.path, external: true };
|
|
808
|
-
}
|
|
809
|
-
const nodeModulesIndex = result.path.indexOf("node_modules");
|
|
810
|
-
if (nodeModulesIndex === -1) {
|
|
811
|
-
return result;
|
|
812
|
-
}
|
|
813
|
-
const isNested = result.path.includes("node_modules", nodeModulesIndex + 14);
|
|
814
|
-
if (isNested) {
|
|
815
|
-
return { path: args.path, external: true };
|
|
816
|
-
}
|
|
817
|
-
return { path: args.path, external: true };
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
};
|
|
821
825
|
await esbuild.build({
|
|
822
826
|
entryPoints: projectFiles.map((f) => path.join(f.parentPath, f.name)),
|
|
823
827
|
bundle: true,
|