elegance-js 1.11.18 → 1.11.20

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.
@@ -691,26 +691,31 @@ var buildPage = async (DIST_DIR2, directory, filePath, name) => {
691
691
  entryPoints: [filePath],
692
692
  outfile: filePath,
693
693
  allowOverwrite: true,
694
- bundle: false,
695
- format: "esm",
694
+ bundle: true,
695
+ format: "cjs",
696
+ platform: "node",
696
697
  plugins: [
697
698
  {
698
- name: "wrap-esm",
699
+ name: "wrap-cjs",
699
700
  setup(build2) {
700
701
  build2.onEnd(async () => {
701
702
  const fs2 = await import("fs/promises");
702
703
  const code = await fs2.readFile(build2.initialOptions.outfile, "utf8");
703
- const wrapped = `export async function construct() {
704
+ const wrapped = `export function construct() {
704
705
  const exports = {};
705
- ${code.replace(/export\s+(const|let|var|function|class)\s+(\w+)/g, "exports.$2 = $2; $1 $2").split("\n").map((l) => " " + l).join("\n")}
706
+ const module = { exports };
707
+ (function(exports, module) {
708
+ ${code.split("\n").map((l) => " " + l).join("\n")}
709
+ })(exports, module);
706
710
 
707
- return exports;
711
+ return module.exports;
708
712
  }
709
713
  `;
710
714
  await fs2.writeFile(build2.initialOptions.outfile, wrapped);
711
715
  });
712
716
  }
713
- }
717
+ },
718
+ externalPackagesPlugin
714
719
  ]
715
720
  });
716
721
  return false;
@@ -754,6 +759,35 @@ var buildPage = async (DIST_DIR2, directory, filePath, name) => {
754
759
  );
755
760
  return sendHardReloadInstruction === true;
756
761
  };
762
+ var recursionFlag = Symbol("external-node-modules-recursion");
763
+ var externalPackagesPlugin = {
764
+ name: "external-packages",
765
+ setup(build2) {
766
+ build2.onResolve({ filter: /^[^./]/ }, async (args) => {
767
+ if (args.pluginData?.[recursionFlag]) {
768
+ return;
769
+ }
770
+ const result = await build2.resolve(args.path, {
771
+ resolveDir: args.resolveDir,
772
+ kind: args.kind,
773
+ importer: args.importer,
774
+ pluginData: { [recursionFlag]: true }
775
+ });
776
+ if (result.errors.length > 0 || result.external || !result.path) {
777
+ return { path: args.path, external: true };
778
+ }
779
+ const nodeModulesIndex = result.path.indexOf("node_modules");
780
+ if (nodeModulesIndex === -1) {
781
+ return result;
782
+ }
783
+ const isNested = result.path.includes("node_modules", nodeModulesIndex + 14);
784
+ if (isNested) {
785
+ return { path: args.path, external: true };
786
+ }
787
+ return { path: args.path, external: true };
788
+ });
789
+ }
790
+ };
757
791
  var build = async () => {
758
792
  if (options.quiet === true) {
759
793
  console.log = function() {
@@ -788,36 +822,7 @@ var build = async () => {
788
822
  }
789
823
  const projectFiles = getProjectFiles(options.pagesDirectory);
790
824
  const start = performance.now();
791
- const recursionFlag = Symbol("external-node-modules-recursion");
792
825
  {
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
826
  await esbuild.build({
822
827
  entryPoints: projectFiles.map((f) => path.join(f.parentPath, f.name)),
823
828
  bundle: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "1.11.18",
3
+ "version": "1.11.20",
4
4
  "description": "Web-Framework",
5
5
  "type": "module",
6
6
  "bin": {