@plumeria/compiler 8.0.1 → 8.0.2

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ const core_1 = require("@swc/core");
8
8
  const zss_engine_1 = require("zss-engine");
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const utils_1 = require("@plumeria/utils");
11
+ const utils_2 = require("@plumeria/utils");
11
12
  function compileCSS(options) {
12
13
  const { include, exclude, cwd = process.cwd() } = options;
13
14
  const allSheets = new Set();
@@ -23,6 +24,10 @@ function compileCSS(options) {
23
24
  tsx: true,
24
25
  target: 'es2022',
25
26
  });
27
+ const leadingLen = (0, utils_2.getLeadingCommentLength)(source);
28
+ const sourceBuffer = Buffer.from(source, 'utf-8');
29
+ const leadingBytes = Buffer.byteLength(source.slice(0, leadingLen), 'utf-8');
30
+ const baseByteOffset = ast.span.start - leadingBytes;
26
31
  const scannedTables = (0, utils_1.scanAll)();
27
32
  const localConsts = (0, utils_1.collectLocalConsts)(ast);
28
33
  const resourcePath = filePath;
@@ -298,7 +303,9 @@ function compileCSS(options) {
298
303
  }
299
304
  if (handledAsObjectArg)
300
305
  continue;
301
- const getSource = (node) => source.substring(node.span.start - ast.span.start, node.span.end - ast.span.start);
306
+ const getSource = (node) => sourceBuffer
307
+ .subarray(node.span.start - baseByteOffset, node.span.end - baseByteOffset)
308
+ .toString('utf-8');
302
309
  const collectConditions = (node, testStrings = []) => {
303
310
  const staticStyle = resolveStyleObject(node);
304
311
  if (staticStyle) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/compiler",
3
- "version": "8.0.1",
3
+ "version": "8.0.2",
4
4
  "description": "Plumeria swc based compiler for statically extracting css",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  "dist/"
22
22
  ],
23
23
  "dependencies": {
24
- "@plumeria/utils": "^8.0.1"
24
+ "@plumeria/utils": "^8.0.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@swc/core": "1.15.8",