@jsenv/core 40.12.10 → 40.12.12
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/build/build.js +22 -15
- package/dist/client/import_meta_css/import_meta_css_build.js +2 -2
- package/{src/plugins/import_meta_css/client/import_meta_css.js → dist/client/import_meta_css/import_meta_css_dev.js} +4 -1
- package/dist/start_dev_server/start_dev_server.js +22 -15
- package/package.json +1 -1
- package/src/plugins/import_meta_css/client/import_meta_css_build.js +1 -1
- package/{dist/client/import_meta_css/import_meta_css.js → src/plugins/import_meta_css/client/import_meta_css_dev.js} +2 -3
- package/src/plugins/import_meta_css/jsenv_plugin_import_meta_css.js +22 -15
package/dist/build/build.js
CHANGED
|
@@ -7906,9 +7906,9 @@ const jsenvPluginNodeRuntime = ({ runtimeCompat }) => {
|
|
|
7906
7906
|
|
|
7907
7907
|
|
|
7908
7908
|
const jsenvPluginImportMetaCss = () => {
|
|
7909
|
-
const
|
|
7910
|
-
.resolve("../client/import_meta_css/
|
|
7911
|
-
const
|
|
7909
|
+
const importMetaCssDevClientFileUrl = import.meta
|
|
7910
|
+
.resolve("../client/import_meta_css/import_meta_css_dev.js");
|
|
7911
|
+
const importMetaCssBuildClientFileUrl = import.meta
|
|
7912
7912
|
.resolve("../client/import_meta_css/import_meta_css_build.js");
|
|
7913
7913
|
|
|
7914
7914
|
return {
|
|
@@ -7916,7 +7916,11 @@ const jsenvPluginImportMetaCss = () => {
|
|
|
7916
7916
|
appliesDuring: "*",
|
|
7917
7917
|
transformUrlContent: {
|
|
7918
7918
|
js_module: async (urlInfo) => {
|
|
7919
|
-
if (
|
|
7919
|
+
if (
|
|
7920
|
+
!urlInfo.content.includes("import.meta.css") ||
|
|
7921
|
+
// there is already our installImportMetaCssBuild in the file
|
|
7922
|
+
urlInfo.content.includes("installImportMetaCssBuild")
|
|
7923
|
+
) {
|
|
7920
7924
|
return null;
|
|
7921
7925
|
}
|
|
7922
7926
|
const { metadata } = await applyBabelPlugins({
|
|
@@ -7931,12 +7935,15 @@ const jsenvPluginImportMetaCss = () => {
|
|
|
7931
7935
|
return null;
|
|
7932
7936
|
}
|
|
7933
7937
|
return injectImportMetaCss(urlInfo, {
|
|
7938
|
+
importFrom: urlInfo.context.build
|
|
7939
|
+
? importMetaCssBuildClientFileUrl
|
|
7940
|
+
: importMetaCssDevClientFileUrl,
|
|
7941
|
+
importName: urlInfo.context.build
|
|
7942
|
+
? "installImportMetaCssBuild"
|
|
7943
|
+
: "installImportMetaCssDev",
|
|
7934
7944
|
importAs: urlInfo.context.build
|
|
7935
|
-
? "
|
|
7936
|
-
: "
|
|
7937
|
-
specifier: urlInfo.context.build
|
|
7938
|
-
? importMetaCssBuildFileUrl
|
|
7939
|
-
: importMetaCssClientFileUrl,
|
|
7945
|
+
? "__installImportMetaCssBuild__"
|
|
7946
|
+
: "__installImportMetaCssDev__",
|
|
7940
7947
|
});
|
|
7941
7948
|
},
|
|
7942
7949
|
},
|
|
@@ -7974,21 +7981,21 @@ const babelPluginMetadataUsesImportMetaCss = () => {
|
|
|
7974
7981
|
};
|
|
7975
7982
|
};
|
|
7976
7983
|
|
|
7977
|
-
const injectImportMetaCss = (urlInfo, {
|
|
7984
|
+
const injectImportMetaCss = (urlInfo, { importFrom, importName, importAs }) => {
|
|
7978
7985
|
const importMetaCssClientFileReference = urlInfo.dependencies.inject({
|
|
7979
7986
|
parentUrl: urlInfo.url,
|
|
7980
7987
|
type: "js_import",
|
|
7981
7988
|
expectedType: "js_module",
|
|
7982
|
-
specifier,
|
|
7989
|
+
specifier: importFrom,
|
|
7983
7990
|
});
|
|
7984
7991
|
let importVariableName;
|
|
7985
7992
|
let importBeforeFrom;
|
|
7986
|
-
if (importAs !==
|
|
7987
|
-
importBeforeFrom = `{
|
|
7993
|
+
if (importAs !== importName) {
|
|
7994
|
+
importBeforeFrom = `{ ${importName} as ${importAs} }`;
|
|
7988
7995
|
importVariableName = importAs;
|
|
7989
7996
|
} else {
|
|
7990
|
-
importBeforeFrom = `{
|
|
7991
|
-
importVariableName =
|
|
7997
|
+
importBeforeFrom = `{ ${importName} } }`;
|
|
7998
|
+
importVariableName = importName;
|
|
7992
7999
|
}
|
|
7993
8000
|
let prelude = `import ${importBeforeFrom} from ${importMetaCssClientFileReference.generatedSpecifier};
|
|
7994
8001
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const installImportMetaCssBuild = (importMeta) => {
|
|
2
2
|
const stylesheet = new CSSStyleSheet({ baseUrl: importMeta.url });
|
|
3
3
|
|
|
4
4
|
let called = false;
|
|
@@ -19,4 +19,4 @@ const installImportMetaCss = (importMeta) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export { installImportMetaCssBuild };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const installImportMetaCssDev = (importMeta) => {
|
|
2
2
|
let cssText = "";
|
|
3
3
|
let stylesheet = new CSSStyleSheet({ baseUrl: importMeta.url });
|
|
4
4
|
let adopted = false;
|
|
@@ -32,6 +32,7 @@ export const installImportMetaCss = (importMeta) => {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
Object.defineProperty(importMeta, "css", {
|
|
35
|
+
configurable: true,
|
|
35
36
|
get() {
|
|
36
37
|
return css;
|
|
37
38
|
},
|
|
@@ -43,3 +44,5 @@ export const installImportMetaCss = (importMeta) => {
|
|
|
43
44
|
|
|
44
45
|
return css.remove;
|
|
45
46
|
};
|
|
47
|
+
|
|
48
|
+
export { installImportMetaCssDev };
|
|
@@ -7947,9 +7947,9 @@ const jsenvPluginNodeRuntime = ({ runtimeCompat }) => {
|
|
|
7947
7947
|
|
|
7948
7948
|
|
|
7949
7949
|
const jsenvPluginImportMetaCss = () => {
|
|
7950
|
-
const
|
|
7951
|
-
.resolve("../client/import_meta_css/
|
|
7952
|
-
const
|
|
7950
|
+
const importMetaCssDevClientFileUrl = import.meta
|
|
7951
|
+
.resolve("../client/import_meta_css/import_meta_css_dev.js");
|
|
7952
|
+
const importMetaCssBuildClientFileUrl = import.meta
|
|
7953
7953
|
.resolve("../client/import_meta_css/import_meta_css_build.js");
|
|
7954
7954
|
|
|
7955
7955
|
return {
|
|
@@ -7957,7 +7957,11 @@ const jsenvPluginImportMetaCss = () => {
|
|
|
7957
7957
|
appliesDuring: "*",
|
|
7958
7958
|
transformUrlContent: {
|
|
7959
7959
|
js_module: async (urlInfo) => {
|
|
7960
|
-
if (
|
|
7960
|
+
if (
|
|
7961
|
+
!urlInfo.content.includes("import.meta.css") ||
|
|
7962
|
+
// there is already our installImportMetaCssBuild in the file
|
|
7963
|
+
urlInfo.content.includes("installImportMetaCssBuild")
|
|
7964
|
+
) {
|
|
7961
7965
|
return null;
|
|
7962
7966
|
}
|
|
7963
7967
|
const { metadata } = await applyBabelPlugins({
|
|
@@ -7972,12 +7976,15 @@ const jsenvPluginImportMetaCss = () => {
|
|
|
7972
7976
|
return null;
|
|
7973
7977
|
}
|
|
7974
7978
|
return injectImportMetaCss(urlInfo, {
|
|
7979
|
+
importFrom: urlInfo.context.build
|
|
7980
|
+
? importMetaCssBuildClientFileUrl
|
|
7981
|
+
: importMetaCssDevClientFileUrl,
|
|
7982
|
+
importName: urlInfo.context.build
|
|
7983
|
+
? "installImportMetaCssBuild"
|
|
7984
|
+
: "installImportMetaCssDev",
|
|
7975
7985
|
importAs: urlInfo.context.build
|
|
7976
|
-
? "
|
|
7977
|
-
: "
|
|
7978
|
-
specifier: urlInfo.context.build
|
|
7979
|
-
? importMetaCssBuildFileUrl
|
|
7980
|
-
: importMetaCssClientFileUrl,
|
|
7986
|
+
? "__installImportMetaCssBuild__"
|
|
7987
|
+
: "__installImportMetaCssDev__",
|
|
7981
7988
|
});
|
|
7982
7989
|
},
|
|
7983
7990
|
},
|
|
@@ -8015,21 +8022,21 @@ const babelPluginMetadataUsesImportMetaCss = () => {
|
|
|
8015
8022
|
};
|
|
8016
8023
|
};
|
|
8017
8024
|
|
|
8018
|
-
const injectImportMetaCss = (urlInfo, {
|
|
8025
|
+
const injectImportMetaCss = (urlInfo, { importFrom, importName, importAs }) => {
|
|
8019
8026
|
const importMetaCssClientFileReference = urlInfo.dependencies.inject({
|
|
8020
8027
|
parentUrl: urlInfo.url,
|
|
8021
8028
|
type: "js_import",
|
|
8022
8029
|
expectedType: "js_module",
|
|
8023
|
-
specifier,
|
|
8030
|
+
specifier: importFrom,
|
|
8024
8031
|
});
|
|
8025
8032
|
let importVariableName;
|
|
8026
8033
|
let importBeforeFrom;
|
|
8027
|
-
if (importAs !==
|
|
8028
|
-
importBeforeFrom = `{
|
|
8034
|
+
if (importAs !== importName) {
|
|
8035
|
+
importBeforeFrom = `{ ${importName} as ${importAs} }`;
|
|
8029
8036
|
importVariableName = importAs;
|
|
8030
8037
|
} else {
|
|
8031
|
-
importBeforeFrom = `{
|
|
8032
|
-
importVariableName =
|
|
8038
|
+
importBeforeFrom = `{ ${importName} } }`;
|
|
8039
|
+
importVariableName = importName;
|
|
8033
8040
|
}
|
|
8034
8041
|
let prelude = `import ${importBeforeFrom} from ${importMetaCssClientFileReference.generatedSpecifier};
|
|
8035
8042
|
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
export const installImportMetaCssDev = (importMeta) => {
|
|
2
2
|
let cssText = "";
|
|
3
3
|
let stylesheet = new CSSStyleSheet({ baseUrl: importMeta.url });
|
|
4
4
|
let adopted = false;
|
|
@@ -32,6 +32,7 @@ const installImportMetaCss = (importMeta) => {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
Object.defineProperty(importMeta, "css", {
|
|
35
|
+
configurable: true,
|
|
35
36
|
get() {
|
|
36
37
|
return css;
|
|
37
38
|
},
|
|
@@ -43,5 +44,3 @@ const installImportMetaCss = (importMeta) => {
|
|
|
43
44
|
|
|
44
45
|
return css.remove;
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
export { installImportMetaCss };
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
import { applyBabelPlugins } from "@jsenv/ast";
|
|
27
27
|
|
|
28
28
|
export const jsenvPluginImportMetaCss = () => {
|
|
29
|
-
const
|
|
30
|
-
.resolve("./client/
|
|
31
|
-
const
|
|
29
|
+
const importMetaCssDevClientFileUrl = import.meta
|
|
30
|
+
.resolve("./client/import_meta_css_dev.js");
|
|
31
|
+
const importMetaCssBuildClientFileUrl = import.meta
|
|
32
32
|
.resolve("./client/import_meta_css_build.js");
|
|
33
33
|
|
|
34
34
|
return {
|
|
@@ -36,7 +36,11 @@ export const jsenvPluginImportMetaCss = () => {
|
|
|
36
36
|
appliesDuring: "*",
|
|
37
37
|
transformUrlContent: {
|
|
38
38
|
js_module: async (urlInfo) => {
|
|
39
|
-
if (
|
|
39
|
+
if (
|
|
40
|
+
!urlInfo.content.includes("import.meta.css") ||
|
|
41
|
+
// there is already our installImportMetaCssBuild in the file
|
|
42
|
+
urlInfo.content.includes("installImportMetaCssBuild")
|
|
43
|
+
) {
|
|
40
44
|
return null;
|
|
41
45
|
}
|
|
42
46
|
const { metadata } = await applyBabelPlugins({
|
|
@@ -51,12 +55,15 @@ export const jsenvPluginImportMetaCss = () => {
|
|
|
51
55
|
return null;
|
|
52
56
|
}
|
|
53
57
|
return injectImportMetaCss(urlInfo, {
|
|
58
|
+
importFrom: urlInfo.context.build
|
|
59
|
+
? importMetaCssBuildClientFileUrl
|
|
60
|
+
: importMetaCssDevClientFileUrl,
|
|
61
|
+
importName: urlInfo.context.build
|
|
62
|
+
? "installImportMetaCssBuild"
|
|
63
|
+
: "installImportMetaCssDev",
|
|
54
64
|
importAs: urlInfo.context.build
|
|
55
|
-
? "
|
|
56
|
-
: "
|
|
57
|
-
specifier: urlInfo.context.build
|
|
58
|
-
? importMetaCssBuildFileUrl
|
|
59
|
-
: importMetaCssClientFileUrl,
|
|
65
|
+
? "__installImportMetaCssBuild__"
|
|
66
|
+
: "__installImportMetaCssDev__",
|
|
60
67
|
});
|
|
61
68
|
},
|
|
62
69
|
},
|
|
@@ -94,21 +101,21 @@ const babelPluginMetadataUsesImportMetaCss = () => {
|
|
|
94
101
|
};
|
|
95
102
|
};
|
|
96
103
|
|
|
97
|
-
const injectImportMetaCss = (urlInfo, {
|
|
104
|
+
const injectImportMetaCss = (urlInfo, { importFrom, importName, importAs }) => {
|
|
98
105
|
const importMetaCssClientFileReference = urlInfo.dependencies.inject({
|
|
99
106
|
parentUrl: urlInfo.url,
|
|
100
107
|
type: "js_import",
|
|
101
108
|
expectedType: "js_module",
|
|
102
|
-
specifier,
|
|
109
|
+
specifier: importFrom,
|
|
103
110
|
});
|
|
104
111
|
let importVariableName;
|
|
105
112
|
let importBeforeFrom;
|
|
106
|
-
if (importAs && importAs !==
|
|
107
|
-
importBeforeFrom = `{
|
|
113
|
+
if (importAs && importAs !== importName) {
|
|
114
|
+
importBeforeFrom = `{ ${importName} as ${importAs} }`;
|
|
108
115
|
importVariableName = importAs;
|
|
109
116
|
} else {
|
|
110
|
-
importBeforeFrom = `{
|
|
111
|
-
importVariableName =
|
|
117
|
+
importBeforeFrom = `{ ${importName} } }`;
|
|
118
|
+
importVariableName = importName;
|
|
112
119
|
}
|
|
113
120
|
let prelude = `import ${importBeforeFrom} from ${importMetaCssClientFileReference.generatedSpecifier};
|
|
114
121
|
|