vite-plugin-qingkuai 1.0.5 → 1.0.6

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
@@ -3,7 +3,6 @@
3
3
  var node_path = require('node:path');
4
4
  var node_fs = require('node:fs');
5
5
  var node_crypto = require('node:crypto');
6
- var sourceMapJs = require('source-map-js');
7
6
  var sourcemapCodec = require('@jridgewell/sourcemap-codec');
8
7
  var compiler = require('qingkuai/compiler');
9
8
  var postcss = require('postcss');
@@ -42,26 +41,12 @@ function offsetSourceMap(mappings, sourceIndex, preLine, preColumn) {
42
41
  });
43
42
  });
44
43
  }
45
- function getSourceFile(sourcemap, line, column) {
46
- const consumer = new sourceMapJs.SourceMapConsumer({
47
- ...sourcemap,
48
- version: sourcemap.version.toString()
49
- });
50
- return consumer.originalPositionFor({
51
- line,
52
- column
53
- }).source;
54
- }
55
44
 
56
45
  async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
57
46
  const processor = postcss([
58
47
  {
59
48
  postcssPlugin: "postcss-attach-scope-qingkuai",
60
49
  Rule(rule) {
61
- const { line, column } = rule.source.start;
62
- if (map && getSourceFile(map, line, column) !== sourceFile) {
63
- return;
64
- }
65
50
  rule.selector = selectorParser((selectors) => {
66
51
  selectors.each((selector) => {
67
52
  const index = selector.nodes.findLastIndex(({ type }) => {
@@ -129,7 +114,7 @@ function qingkuaiPlugin() {
129
114
  }
130
115
  if (importer?.endsWith(".qk") && !node_path.extname(id)) {
131
116
  const qingkuaiConfig = getQingkuaiConfiguration(id);
132
- return id + (qingkuaiConfig.resolveImportExtension ? ".qk" : "");
117
+ return node_path.join(node_path.dirname(importer), id + (qingkuaiConfig.resolveImportExtension ? ".qk" : ""));
133
118
  }
134
119
  },
135
120
  async load(id) {
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { join, basename, extname, dirname } from 'node:path';
2
2
  import { readdirSync, existsSync, readFileSync } from 'node:fs';
3
3
  import { randomBytes } from 'node:crypto';
4
- import { SourceMapConsumer } from 'source-map-js';
5
4
  import { decode, encode } from '@jridgewell/sourcemap-codec';
6
5
  import { compile, util } from 'qingkuai/compiler';
7
6
  import postcss from 'postcss';
@@ -40,26 +39,12 @@ function offsetSourceMap(mappings, sourceIndex, preLine, preColumn) {
40
39
  });
41
40
  });
42
41
  }
43
- function getSourceFile(sourcemap, line, column) {
44
- const consumer = new SourceMapConsumer({
45
- ...sourcemap,
46
- version: sourcemap.version.toString()
47
- });
48
- return consumer.originalPositionFor({
49
- line,
50
- column
51
- }).source;
52
- }
53
42
 
54
43
  async function attachScopeForStyleSelectors(code, hash, sourceFile, map) {
55
44
  const processor = postcss([
56
45
  {
57
46
  postcssPlugin: "postcss-attach-scope-qingkuai",
58
47
  Rule(rule) {
59
- const { line, column } = rule.source.start;
60
- if (map && getSourceFile(map, line, column) !== sourceFile) {
61
- return;
62
- }
63
48
  rule.selector = selectorParser((selectors) => {
64
49
  selectors.each((selector) => {
65
50
  const index = selector.nodes.findLastIndex(({ type }) => {
@@ -127,7 +112,7 @@ function qingkuaiPlugin() {
127
112
  }
128
113
  if (importer?.endsWith(".qk") && !extname(id)) {
129
114
  const qingkuaiConfig = getQingkuaiConfiguration(id);
130
- return id + (qingkuaiConfig.resolveImportExtension ? ".qk" : "");
115
+ return join(dirname(importer), id + (qingkuaiConfig.resolveImportExtension ? ".qk" : ""));
131
116
  }
132
117
  },
133
118
  async load(id) {
@@ -1,4 +1,2 @@
1
- import type { SourceMap } from "./types";
2
1
  import type { SourceMapMappings } from "@jridgewell/sourcemap-codec";
3
2
  export declare function offsetSourceMap(mappings: string, sourceIndex: number, preLine: number, preColumn: number): SourceMapMappings;
4
- export declare function getSourceFile(sourcemap: SourceMap, line: number, column: number): string;
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.5",
5
+ "version": "1.0.6",
6
6
  "type": "module",
7
7
  "keywords": [
8
8
  "vite",
@@ -39,7 +39,6 @@
39
39
  "dependencies": {
40
40
  "@jridgewell/sourcemap-codec": "^1.5.0",
41
41
  "postcss": "^8.5.3",
42
- "postcss-selector-parser": "^7.1.0",
43
- "source-map-js": "^1.2.1"
42
+ "postcss-selector-parser": "^7.1.0"
44
43
  }
45
44
  }