elegance-js 1.11.19 → 1.11.21
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 +16 -28
- package/package.json +1 -1
package/dist/page_compiler.mjs
CHANGED
|
@@ -687,36 +687,24 @@ var buildPage = async (DIST_DIR2, directory, filePath, name) => {
|
|
|
687
687
|
pageElements = page;
|
|
688
688
|
metadata = pageMetadata;
|
|
689
689
|
if (isDynamicPage === true) {
|
|
690
|
-
await esbuild.build({
|
|
690
|
+
const result = await esbuild.build({
|
|
691
691
|
entryPoints: [filePath],
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
name: "wrap-cjs",
|
|
699
|
-
setup(build2) {
|
|
700
|
-
build2.onEnd(async () => {
|
|
701
|
-
const fs2 = await import("fs/promises");
|
|
702
|
-
const code = await fs2.readFile(build2.initialOptions.outfile, "utf8");
|
|
703
|
-
const wrapped = `export function construct() {
|
|
704
|
-
const exports = {};
|
|
705
|
-
const module = { exports };
|
|
706
|
-
(function(exports, module) {
|
|
707
|
-
${code.split("\n").map((l) => " " + l).join("\n")}
|
|
708
|
-
})(exports, module);
|
|
709
|
-
|
|
710
|
-
return module.exports;
|
|
711
|
-
}
|
|
712
|
-
`;
|
|
713
|
-
await fs2.writeFile(build2.initialOptions.outfile, wrapped);
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
},
|
|
717
|
-
externalPackagesPlugin
|
|
718
|
-
]
|
|
692
|
+
bundle: false,
|
|
693
|
+
format: "iife",
|
|
694
|
+
globalName: "__exports",
|
|
695
|
+
write: false,
|
|
696
|
+
platform: "node",
|
|
697
|
+
plugins: [externalPackagesPlugin]
|
|
719
698
|
});
|
|
699
|
+
let iifeCode = result.outputFiles[0].text;
|
|
700
|
+
iifeCode = iifeCode.replace(/^var __exports = /, "");
|
|
701
|
+
const wrappedCode = `import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
702
|
+
|
|
703
|
+
export function construct() {
|
|
704
|
+
${iifeCode}
|
|
705
|
+
return __exports
|
|
706
|
+
}`;
|
|
707
|
+
fs.writeFileSync(filePath, wrappedCode);
|
|
720
708
|
return false;
|
|
721
709
|
}
|
|
722
710
|
fs.rmSync(filePath, { force: true });
|