vite-plugin-qingkuai 1.0.2 → 1.0.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.cjs +10 -9
- package/dist/index.js +10 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -53,13 +53,13 @@ function getSourceFile(sourcemap, line, column) {
|
|
|
53
53
|
}).source;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async function attachScopeForStyleSelectors(code, hash,
|
|
56
|
+
async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
|
|
57
57
|
const processor = postcss([
|
|
58
58
|
{
|
|
59
59
|
postcssPlugin: "postcss-attach-scope-qingkuai",
|
|
60
60
|
Rule(rule) {
|
|
61
61
|
const { line, column } = rule.source.start;
|
|
62
|
-
if (getSourceFile(map, line, column) !== sourceFile) {
|
|
62
|
+
if (map && getSourceFile(map, line, column) !== sourceFile) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
rule.selector = selectorParser((selectors) => {
|
|
@@ -84,7 +84,7 @@ async function attachScopeForStyleSelectors(code, hash, map, sourceFile) {
|
|
|
84
84
|
}
|
|
85
85
|
]);
|
|
86
86
|
const ret = await processor.process(code, {
|
|
87
|
-
from:
|
|
87
|
+
from: sourceFile,
|
|
88
88
|
map: {
|
|
89
89
|
prev: map,
|
|
90
90
|
annotation: false
|
|
@@ -100,9 +100,10 @@ function qingkuaiPlugin() {
|
|
|
100
100
|
let viteConfig;
|
|
101
101
|
const compileResultCache = /* @__PURE__ */ new Map();
|
|
102
102
|
const qingkuaiConfigurations = /* @__PURE__ */ new Map();
|
|
103
|
+
const qingkuaiPackageServeRE = /node_modules\/\.vite\/deps\/chunk.*$/;
|
|
103
104
|
const confIdentifierRE = /__qk_expose_(?:dependencies|destructions)__/g;
|
|
104
105
|
const styleIdRE = /^virtual:\[\d+\].*?\.qk.(?:css|s[ac]ss|less|stylus|postcss)\?\d{13}$/;
|
|
105
|
-
const
|
|
106
|
+
const qingkuaiPackageBuildRE = /node_modules\/qingkuai\/dist\/esm\/(?:chunks|runtime)\/\w+\.js$/;
|
|
106
107
|
return {
|
|
107
108
|
name: "qingkuai-compiler",
|
|
108
109
|
config(_, env) {
|
|
@@ -163,8 +164,8 @@ function qingkuaiPlugin() {
|
|
|
163
164
|
const attachScopeResult = await attachScopeForStyleSelectors(
|
|
164
165
|
preprocessRes.code,
|
|
165
166
|
compileRes.hashId,
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
virtualFileName,
|
|
168
|
+
assertedPreprocessMap
|
|
168
169
|
);
|
|
169
170
|
const offsetMappings = sourcemapCodec.encode(
|
|
170
171
|
offsetSourceMap(
|
|
@@ -179,8 +180,8 @@ function qingkuaiPlugin() {
|
|
|
179
180
|
map: {
|
|
180
181
|
version: 3,
|
|
181
182
|
mappings: offsetMappings,
|
|
182
|
-
names: assertedPreprocessMap
|
|
183
|
-
sources: [...assertedPreprocessMap.sources.slice(0, -1), fileId]
|
|
183
|
+
names: assertedPreprocessMap?.names || [],
|
|
184
|
+
sources: [...assertedPreprocessMap ? assertedPreprocessMap.sources.slice(0, -1) : [], fileId]
|
|
184
185
|
}
|
|
185
186
|
};
|
|
186
187
|
}
|
|
@@ -188,7 +189,7 @@ function qingkuaiPlugin() {
|
|
|
188
189
|
async transform(src, id) {
|
|
189
190
|
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
190
191
|
if (!id.endsWith(".qk")) {
|
|
191
|
-
if (!isDev &&
|
|
192
|
+
if (isDev && qingkuaiPackageServeRE.test(id) || !isDev && qingkuaiPackageBuildRE.test(id)) {
|
|
192
193
|
const ret = src.replace(confIdentifierRE, (s) => {
|
|
193
194
|
switch (s) {
|
|
194
195
|
case "__qk_expose_dependencies__":
|
package/dist/index.js
CHANGED
|
@@ -51,13 +51,13 @@ function getSourceFile(sourcemap, line, column) {
|
|
|
51
51
|
}).source;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
async function attachScopeForStyleSelectors(code, hash,
|
|
54
|
+
async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
|
|
55
55
|
const processor = postcss([
|
|
56
56
|
{
|
|
57
57
|
postcssPlugin: "postcss-attach-scope-qingkuai",
|
|
58
58
|
Rule(rule) {
|
|
59
59
|
const { line, column } = rule.source.start;
|
|
60
|
-
if (getSourceFile(map, line, column) !== sourceFile) {
|
|
60
|
+
if (map && getSourceFile(map, line, column) !== sourceFile) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
rule.selector = selectorParser((selectors) => {
|
|
@@ -82,7 +82,7 @@ async function attachScopeForStyleSelectors(code, hash, map, sourceFile) {
|
|
|
82
82
|
}
|
|
83
83
|
]);
|
|
84
84
|
const ret = await processor.process(code, {
|
|
85
|
-
from:
|
|
85
|
+
from: sourceFile,
|
|
86
86
|
map: {
|
|
87
87
|
prev: map,
|
|
88
88
|
annotation: false
|
|
@@ -98,9 +98,10 @@ function qingkuaiPlugin() {
|
|
|
98
98
|
let viteConfig;
|
|
99
99
|
const compileResultCache = /* @__PURE__ */ new Map();
|
|
100
100
|
const qingkuaiConfigurations = /* @__PURE__ */ new Map();
|
|
101
|
+
const qingkuaiPackageServeRE = /node_modules\/\.vite\/deps\/chunk.*$/;
|
|
101
102
|
const confIdentifierRE = /__qk_expose_(?:dependencies|destructions)__/g;
|
|
102
103
|
const styleIdRE = /^virtual:\[\d+\].*?\.qk.(?:css|s[ac]ss|less|stylus|postcss)\?\d{13}$/;
|
|
103
|
-
const
|
|
104
|
+
const qingkuaiPackageBuildRE = /node_modules\/qingkuai\/dist\/esm\/(?:chunks|runtime)\/\w+\.js$/;
|
|
104
105
|
return {
|
|
105
106
|
name: "qingkuai-compiler",
|
|
106
107
|
config(_, env) {
|
|
@@ -161,8 +162,8 @@ function qingkuaiPlugin() {
|
|
|
161
162
|
const attachScopeResult = await attachScopeForStyleSelectors(
|
|
162
163
|
preprocessRes.code,
|
|
163
164
|
compileRes.hashId,
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
virtualFileName,
|
|
166
|
+
assertedPreprocessMap
|
|
166
167
|
);
|
|
167
168
|
const offsetMappings = encode(
|
|
168
169
|
offsetSourceMap(
|
|
@@ -177,8 +178,8 @@ function qingkuaiPlugin() {
|
|
|
177
178
|
map: {
|
|
178
179
|
version: 3,
|
|
179
180
|
mappings: offsetMappings,
|
|
180
|
-
names: assertedPreprocessMap
|
|
181
|
-
sources: [...assertedPreprocessMap.sources.slice(0, -1), fileId]
|
|
181
|
+
names: assertedPreprocessMap?.names || [],
|
|
182
|
+
sources: [...assertedPreprocessMap ? assertedPreprocessMap.sources.slice(0, -1) : [], fileId]
|
|
182
183
|
}
|
|
183
184
|
};
|
|
184
185
|
}
|
|
@@ -186,7 +187,7 @@ function qingkuaiPlugin() {
|
|
|
186
187
|
async transform(src, id) {
|
|
187
188
|
const qingkuaiConfig = getQingkuaiConfiguration(id);
|
|
188
189
|
if (!id.endsWith(".qk")) {
|
|
189
|
-
if (!isDev &&
|
|
190
|
+
if (isDev && qingkuaiPackageServeRE.test(id) || !isDev && qingkuaiPackageBuildRE.test(id)) {
|
|
190
191
|
const ret = src.replace(confIdentifierRE, (s) => {
|
|
191
192
|
switch (s) {
|
|
192
193
|
case "__qk_expose_dependencies__":
|