@staticbolt/core 1.0.0-beta.31 → 1.0.0-beta.32
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/lib/plugins/index.mjs
CHANGED
|
@@ -2971,6 +2971,7 @@ function transformJsPlugin(options = {}) {
|
|
|
2971
2971
|
},
|
|
2972
2972
|
async transform(inputMetadata) {
|
|
2973
2973
|
for (const { metadata } of filterScriptMetadata(inputMetadata)) {
|
|
2974
|
+
metadata.ast.program.sourceType = metadata.module ? "module" : "script";
|
|
2974
2975
|
const [, transformError] = useBabelTransform({
|
|
2975
2976
|
ast: metadata.ast,
|
|
2976
2977
|
root: this.root,
|
|
@@ -4830,8 +4831,9 @@ function htmlInlineScriptPlugin(options = {}) {
|
|
|
4830
4831
|
}
|
|
4831
4832
|
const scriptMetadataClone = this.clone(scriptMetadata);
|
|
4832
4833
|
await this.rebase(scriptMetadataClone, join(this.root, metadata.filePath));
|
|
4833
|
-
|
|
4834
|
-
|
|
4834
|
+
const isModule = scriptTag.getAttribute("type") === "module";
|
|
4835
|
+
scriptMetadataClone.module = isModule;
|
|
4836
|
+
const metadataID = hashContent((isModule ? "module:" : "script:") + await this.stringify(scriptMetadataClone));
|
|
4835
4837
|
scriptTag.setAttribute(CUSTOM_ATTRIBUTES.MetadataID, metadataID);
|
|
4836
4838
|
metadata.scriptsMetadataList.set(metadataID, scriptMetadataClone);
|
|
4837
4839
|
scriptTag.removeAttribute("src");
|
|
@@ -7090,8 +7092,9 @@ async function htmlLoader(relativePath, code) {
|
|
|
7090
7092
|
type: "js"
|
|
7091
7093
|
});
|
|
7092
7094
|
if (!isScriptMetadata(scriptMetadata)) return [null, /* @__PURE__ */ new Error("Script loader returned non-script metadata")];
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
+
const isTypeModule = script.getAttribute("type") === "module";
|
|
7096
|
+
scriptMetadata.module = isTypeModule;
|
|
7097
|
+
const astID = hashContent((isTypeModule ? "module:" : "script:") + scriptCode);
|
|
7095
7098
|
script.setAttribute(CUSTOM_ATTRIBUTES.MetadataID, astID);
|
|
7096
7099
|
scriptsMetadataList.set(astID, scriptMetadata);
|
|
7097
7100
|
}
|
|
@@ -7553,7 +7556,7 @@ function scriptLoader(relativePath, code) {
|
|
|
7553
7556
|
filePath: relativePath,
|
|
7554
7557
|
id: relativePath,
|
|
7555
7558
|
directDependencies: /* @__PURE__ */ new Set(),
|
|
7556
|
-
module:
|
|
7559
|
+
module: ast.program.sourceType === "module"
|
|
7557
7560
|
}, null];
|
|
7558
7561
|
}
|
|
7559
7562
|
|