@marko/vite 3.1.1 → 3.1.3
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/index.js +18 -23
- package/dist/index.mjs +18 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -416,7 +416,7 @@ function markoPlugin(opts = {}) {
|
|
|
416
416
|
cachedSources.set(id, source);
|
|
417
417
|
}
|
|
418
418
|
if (!query) {
|
|
419
|
-
if (
|
|
419
|
+
if (!isBuild && isCJSModule(id)) {
|
|
420
420
|
const { ast } = await compiler.compile(source, id, {
|
|
421
421
|
cache,
|
|
422
422
|
ast: true,
|
|
@@ -650,30 +650,25 @@ function isEmpty(obj) {
|
|
|
650
650
|
}
|
|
651
651
|
return true;
|
|
652
652
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
let moduleType = moduleTypeMap.get(pkgPath);
|
|
669
|
-
if (!moduleType) {
|
|
670
|
-
const pkg = JSON.parse(import_fs.default.readFileSync(pkgPath, "utf8"));
|
|
671
|
-
moduleType = pkg.type === "module" || pkg.exports ? "esm" : "cjs";
|
|
672
|
-
moduleTypeMap.set(pkgPath, moduleType);
|
|
653
|
+
const cjsModuleLookup = /* @__PURE__ */ new Map();
|
|
654
|
+
function isCJSModule(id) {
|
|
655
|
+
var _a;
|
|
656
|
+
const modulePath = (_a = /^.*[/\\]node_modules[/\\](?:@[^/\\]+[/\\])?[^/\\]+[/\\]/.exec(id)) == null ? void 0 : _a[0];
|
|
657
|
+
if (modulePath) {
|
|
658
|
+
let isCJS = cjsModuleLookup.get(modulePath);
|
|
659
|
+
if (isCJS === void 0) {
|
|
660
|
+
const pkgPath = modulePath + "package.json";
|
|
661
|
+
try {
|
|
662
|
+
const pkg = JSON.parse(import_fs.default.readFileSync(pkgPath, "utf8"));
|
|
663
|
+
isCJS = pkg.type !== "module" && !pkg.exports;
|
|
664
|
+
} catch {
|
|
665
|
+
isCJS = false;
|
|
666
|
+
}
|
|
667
|
+
cjsModuleLookup.set(modulePath, isCJS);
|
|
673
668
|
}
|
|
674
|
-
return
|
|
669
|
+
return isCJS;
|
|
675
670
|
}
|
|
676
|
-
return
|
|
671
|
+
return false;
|
|
677
672
|
}
|
|
678
673
|
function stripVersionAndTimeStamp(id) {
|
|
679
674
|
const queryStart = id.indexOf("?");
|
package/dist/index.mjs
CHANGED
|
@@ -396,7 +396,7 @@ function markoPlugin(opts = {}) {
|
|
|
396
396
|
cachedSources.set(id, source);
|
|
397
397
|
}
|
|
398
398
|
if (!query) {
|
|
399
|
-
if (
|
|
399
|
+
if (!isBuild && isCJSModule(id)) {
|
|
400
400
|
const { ast } = await compiler.compile(source, id, {
|
|
401
401
|
cache,
|
|
402
402
|
ast: true,
|
|
@@ -630,30 +630,25 @@ function isEmpty(obj) {
|
|
|
630
630
|
}
|
|
631
631
|
return true;
|
|
632
632
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
let moduleType = moduleTypeMap.get(pkgPath);
|
|
649
|
-
if (!moduleType) {
|
|
650
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
651
|
-
moduleType = pkg.type === "module" || pkg.exports ? "esm" : "cjs";
|
|
652
|
-
moduleTypeMap.set(pkgPath, moduleType);
|
|
633
|
+
var cjsModuleLookup = /* @__PURE__ */ new Map();
|
|
634
|
+
function isCJSModule(id) {
|
|
635
|
+
var _a;
|
|
636
|
+
const modulePath = (_a = /^.*[/\\]node_modules[/\\](?:@[^/\\]+[/\\])?[^/\\]+[/\\]/.exec(id)) == null ? void 0 : _a[0];
|
|
637
|
+
if (modulePath) {
|
|
638
|
+
let isCJS = cjsModuleLookup.get(modulePath);
|
|
639
|
+
if (isCJS === void 0) {
|
|
640
|
+
const pkgPath = modulePath + "package.json";
|
|
641
|
+
try {
|
|
642
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
643
|
+
isCJS = pkg.type !== "module" && !pkg.exports;
|
|
644
|
+
} catch {
|
|
645
|
+
isCJS = false;
|
|
646
|
+
}
|
|
647
|
+
cjsModuleLookup.set(modulePath, isCJS);
|
|
653
648
|
}
|
|
654
|
-
return
|
|
649
|
+
return isCJS;
|
|
655
650
|
}
|
|
656
|
-
return
|
|
651
|
+
return false;
|
|
657
652
|
}
|
|
658
653
|
function stripVersionAndTimeStamp(id) {
|
|
659
654
|
const queryStart = id.indexOf("?");
|