elegance-js 1.11.20 → 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.
@@ -687,37 +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
- outfile: filePath,
693
- allowOverwrite: true,
694
- bundle: true,
695
- format: "cjs",
692
+ bundle: false,
693
+ format: "iife",
694
+ globalName: "__exports",
695
+ write: false,
696
696
  platform: "node",
697
- plugins: [
698
- {
699
- name: "wrap-cjs",
700
- setup(build2) {
701
- build2.onEnd(async () => {
702
- const fs2 = await import("fs/promises");
703
- const code = await fs2.readFile(build2.initialOptions.outfile, "utf8");
704
- const wrapped = `export function construct() {
705
- const exports = {};
706
- const module = { exports };
707
- (function(exports, module) {
708
- ${code.split("\n").map((l) => " " + l).join("\n")}
709
- })(exports, module);
710
-
711
- return module.exports;
712
- }
713
- `;
714
- await fs2.writeFile(build2.initialOptions.outfile, wrapped);
715
- });
716
- }
717
- },
718
- externalPackagesPlugin
719
- ]
697
+ plugins: [externalPackagesPlugin]
720
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);
721
708
  return false;
722
709
  }
723
710
  fs.rmSync(filePath, { force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "1.11.20",
3
+ "version": "1.11.21",
4
4
  "description": "Web-Framework",
5
5
  "type": "module",
6
6
  "bin": {