@marko/vite 3.1.2 → 3.1.4
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 +19 -26
- package/dist/index.mjs +19 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -76,10 +76,8 @@ function markoPlugin(opts = {}) {
|
|
|
76
76
|
let domConfig;
|
|
77
77
|
let hydrateConfig;
|
|
78
78
|
const resolveVirtualDependency = (from, dep) => {
|
|
79
|
-
const query = `${virtualFileQuery}&id=${encodeURIComponent(
|
|
80
|
-
normalizePath(dep.virtualPath)
|
|
81
|
-
)}`;
|
|
82
79
|
const normalizedFrom = normalizePath(from);
|
|
80
|
+
const query = `${virtualFileQuery}&id=${Buffer.from(dep.virtualPath).toString("base64url") + import_path.default.extname(dep.virtualPath)}`;
|
|
83
81
|
const id = normalizePath(normalizedFrom) + query;
|
|
84
82
|
if (devServer) {
|
|
85
83
|
const prev = virtualFiles.get(id);
|
|
@@ -416,7 +414,7 @@ function markoPlugin(opts = {}) {
|
|
|
416
414
|
cachedSources.set(id, source);
|
|
417
415
|
}
|
|
418
416
|
if (!query) {
|
|
419
|
-
if (!isBuild &&
|
|
417
|
+
if (!isBuild && isCJSModule(id)) {
|
|
420
418
|
const { ast } = await compiler.compile(source, id, {
|
|
421
419
|
cache,
|
|
422
420
|
ast: true,
|
|
@@ -650,30 +648,25 @@ function isEmpty(obj) {
|
|
|
650
648
|
}
|
|
651
649
|
return true;
|
|
652
650
|
}
|
|
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);
|
|
651
|
+
const cjsModuleLookup = /* @__PURE__ */ new Map();
|
|
652
|
+
function isCJSModule(id) {
|
|
653
|
+
var _a;
|
|
654
|
+
const modulePath = (_a = /^.*[/\\]node_modules[/\\](?:@[^/\\]+[/\\])?[^/\\]+[/\\]/.exec(id)) == null ? void 0 : _a[0];
|
|
655
|
+
if (modulePath) {
|
|
656
|
+
let isCJS = cjsModuleLookup.get(modulePath);
|
|
657
|
+
if (isCJS === void 0) {
|
|
658
|
+
const pkgPath = modulePath + "package.json";
|
|
659
|
+
try {
|
|
660
|
+
const pkg = JSON.parse(import_fs.default.readFileSync(pkgPath, "utf8"));
|
|
661
|
+
isCJS = pkg.type !== "module" && !pkg.exports;
|
|
662
|
+
} catch {
|
|
663
|
+
isCJS = false;
|
|
664
|
+
}
|
|
665
|
+
cjsModuleLookup.set(modulePath, isCJS);
|
|
673
666
|
}
|
|
674
|
-
return
|
|
667
|
+
return isCJS;
|
|
675
668
|
}
|
|
676
|
-
return
|
|
669
|
+
return false;
|
|
677
670
|
}
|
|
678
671
|
function stripVersionAndTimeStamp(id) {
|
|
679
672
|
const queryStart = id.indexOf("?");
|
package/dist/index.mjs
CHANGED
|
@@ -56,10 +56,8 @@ function markoPlugin(opts = {}) {
|
|
|
56
56
|
let domConfig;
|
|
57
57
|
let hydrateConfig;
|
|
58
58
|
const resolveVirtualDependency = (from, dep) => {
|
|
59
|
-
const query = `${virtualFileQuery}&id=${encodeURIComponent(
|
|
60
|
-
normalizePath(dep.virtualPath)
|
|
61
|
-
)}`;
|
|
62
59
|
const normalizedFrom = normalizePath(from);
|
|
60
|
+
const query = `${virtualFileQuery}&id=${Buffer.from(dep.virtualPath).toString("base64url") + path.extname(dep.virtualPath)}`;
|
|
63
61
|
const id = normalizePath(normalizedFrom) + query;
|
|
64
62
|
if (devServer) {
|
|
65
63
|
const prev = virtualFiles.get(id);
|
|
@@ -396,7 +394,7 @@ function markoPlugin(opts = {}) {
|
|
|
396
394
|
cachedSources.set(id, source);
|
|
397
395
|
}
|
|
398
396
|
if (!query) {
|
|
399
|
-
if (!isBuild &&
|
|
397
|
+
if (!isBuild && isCJSModule(id)) {
|
|
400
398
|
const { ast } = await compiler.compile(source, id, {
|
|
401
399
|
cache,
|
|
402
400
|
ast: true,
|
|
@@ -630,30 +628,25 @@ function isEmpty(obj) {
|
|
|
630
628
|
}
|
|
631
629
|
return true;
|
|
632
630
|
}
|
|
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);
|
|
631
|
+
var cjsModuleLookup = /* @__PURE__ */ new Map();
|
|
632
|
+
function isCJSModule(id) {
|
|
633
|
+
var _a;
|
|
634
|
+
const modulePath = (_a = /^.*[/\\]node_modules[/\\](?:@[^/\\]+[/\\])?[^/\\]+[/\\]/.exec(id)) == null ? void 0 : _a[0];
|
|
635
|
+
if (modulePath) {
|
|
636
|
+
let isCJS = cjsModuleLookup.get(modulePath);
|
|
637
|
+
if (isCJS === void 0) {
|
|
638
|
+
const pkgPath = modulePath + "package.json";
|
|
639
|
+
try {
|
|
640
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
641
|
+
isCJS = pkg.type !== "module" && !pkg.exports;
|
|
642
|
+
} catch {
|
|
643
|
+
isCJS = false;
|
|
644
|
+
}
|
|
645
|
+
cjsModuleLookup.set(modulePath, isCJS);
|
|
653
646
|
}
|
|
654
|
-
return
|
|
647
|
+
return isCJS;
|
|
655
648
|
}
|
|
656
|
-
return
|
|
649
|
+
return false;
|
|
657
650
|
}
|
|
658
651
|
function stripVersionAndTimeStamp(id) {
|
|
659
652
|
const queryStart = id.indexOf("?");
|