vite-plugin-qingkuai 1.0.3 → 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 CHANGED
@@ -53,13 +53,13 @@ function getSourceFile(sourcemap, line, column) {
53
53
  }).source;
54
54
  }
55
55
 
56
- async function attachScopeForStyleSelectors(code, hash, map, sourceFile) {
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: map.file,
87
+ from: sourceFile,
88
88
  map: {
89
89
  prev: map,
90
90
  annotation: false
@@ -164,8 +164,8 @@ function qingkuaiPlugin() {
164
164
  const attachScopeResult = await attachScopeForStyleSelectors(
165
165
  preprocessRes.code,
166
166
  compileRes.hashId,
167
- assertedPreprocessMap,
168
- virtualFileName
167
+ virtualFileName,
168
+ assertedPreprocessMap
169
169
  );
170
170
  const offsetMappings = sourcemapCodec.encode(
171
171
  offsetSourceMap(
@@ -180,8 +180,8 @@ function qingkuaiPlugin() {
180
180
  map: {
181
181
  version: 3,
182
182
  mappings: offsetMappings,
183
- names: assertedPreprocessMap.names,
184
- sources: [...assertedPreprocessMap.sources.slice(0, -1), fileId]
183
+ names: assertedPreprocessMap?.names || [],
184
+ sources: [...assertedPreprocessMap ? assertedPreprocessMap.sources.slice(0, -1) : [], fileId]
185
185
  }
186
186
  };
187
187
  }
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, map, sourceFile) {
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: map.file,
85
+ from: sourceFile,
86
86
  map: {
87
87
  prev: map,
88
88
  annotation: false
@@ -162,8 +162,8 @@ function qingkuaiPlugin() {
162
162
  const attachScopeResult = await attachScopeForStyleSelectors(
163
163
  preprocessRes.code,
164
164
  compileRes.hashId,
165
- assertedPreprocessMap,
166
- virtualFileName
165
+ virtualFileName,
166
+ assertedPreprocessMap
167
167
  );
168
168
  const offsetMappings = encode(
169
169
  offsetSourceMap(
@@ -178,8 +178,8 @@ function qingkuaiPlugin() {
178
178
  map: {
179
179
  version: 3,
180
180
  mappings: offsetMappings,
181
- names: assertedPreprocessMap.names,
182
- sources: [...assertedPreprocessMap.sources.slice(0, -1), fileId]
181
+ names: assertedPreprocessMap?.names || [],
182
+ sources: [...assertedPreprocessMap ? assertedPreprocessMap.sources.slice(0, -1) : [], fileId]
183
183
  }
184
184
  };
185
185
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "vite-plugin-qingkuai",
3
3
  "author": "mlgq",
4
4
  "license": "MIT",
5
- "version": "1.0.3",
5
+ "version": "1.0.4",
6
6
  "type": "module",
7
7
  "keywords": [
8
8
  "vite",