@marko/vite 4.1.12 → 4.1.13

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.
Files changed (2) hide show
  1. package/dist/index.mjs +15 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -4,7 +4,6 @@ import path5 from "path";
4
4
  import crypto from "crypto";
5
5
  import anyMatch from "anymatch";
6
6
  import { pathToFileURL } from "url";
7
- import { transform as cjsToEsm } from "@chialab/cjs-to-esm";
8
7
 
9
8
  // src/server-entry-template.ts
10
9
  import path from "path";
@@ -664,6 +663,7 @@ var babelCaller = {
664
663
  supportsExportNamespaceFrom: true
665
664
  };
666
665
  var registeredTagLib = false;
666
+ var cjsToEsm;
667
667
  function markoPlugin(opts = {}) {
668
668
  let compiler;
669
669
  let { linked = true } = opts;
@@ -1088,10 +1088,20 @@ function markoPlugin(opts = {}) {
1088
1088
  if (!isBuild) {
1089
1089
  const ext = path5.extname(id);
1090
1090
  if (ext === ".cjs" || ext === ".js" && isCJSModule(id)) {
1091
- try {
1092
- return await cjsToEsm(source);
1093
- } catch {
1094
- return null;
1091
+ if (cjsToEsm === void 0) {
1092
+ try {
1093
+ cjsToEsm = (await import("@chialab/cjs-to-esm")).transform;
1094
+ } catch {
1095
+ cjsToEsm = null;
1096
+ return null;
1097
+ }
1098
+ }
1099
+ if (cjsToEsm) {
1100
+ try {
1101
+ return await cjsToEsm(source);
1102
+ } catch {
1103
+ return null;
1104
+ }
1095
1105
  }
1096
1106
  }
1097
1107
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/vite",
3
3
  "description": "A Marko plugin for Vite",
4
- "version": "4.1.12",
4
+ "version": "4.1.13",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/vite/issues",
7
7
  "dependencies": {