ecij 0.3.0 → 0.4.0

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/README.md CHANGED
@@ -172,6 +172,5 @@ npm test -- -u
172
172
 
173
173
  - Log CSS extraction failures
174
174
  - Scope handling
175
- - Validate that the `css` used refers to the ecij export
176
175
  - Full import/export handling (default/namespace import/export)
177
176
  - Sourcemaps
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { relative } from "node:path";
3
3
  import { cwd } from "node:process";
4
- import { Visitor, parseSync } from "oxc-parser";
5
- import { makeIdFiltersToMatchWithQuery } from "@rolldown/pluginutils";
4
+ import { makeIdFiltersToMatchWithQuery } from "rolldown/filter";
5
+ import { Visitor, parseSync } from "rolldown/utils";
6
6
 
7
7
  //#region src/index.ts
8
8
  const JS_TS_FILE_REGEX = /\.[cm]?[jt]sx?$/;
@@ -103,19 +103,19 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
103
103
  const resolvedId = await context.resolve(source, filePath);
104
104
  if (resolvedId != null) {
105
105
  const { id } = resolvedId;
106
- const { declarations: declarations$1, exportNameToValueMap } = await parseFile(context, id);
106
+ const { declarations, exportNameToValueMap } = await parseFile(context, id);
107
107
  if (exportNameToValueMap.has(imported)) {
108
- if (declarations$1.length !== 0) modulesWithSideEffects.add(id);
108
+ if (declarations.length !== 0) modulesWithSideEffects.add(id);
109
109
  return exportNameToValueMap.get(imported);
110
110
  }
111
111
  }
112
112
  }
113
113
  }
114
- function addProcessedDeclaration(declaration, cssContent$1) {
114
+ function addProcessedDeclaration(declaration, cssContent) {
115
115
  const { className, node } = declaration;
116
116
  cssExtractions.push({
117
117
  className,
118
- cssContent: cssContent$1.trim(),
118
+ cssContent: cssContent.trim(),
119
119
  sourcePosition: node.start
120
120
  });
121
121
  replacements.push({
@@ -126,16 +126,16 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
126
126
  }
127
127
  for (const declaration of declarations) {
128
128
  if (declaration.hasInterpolations) continue;
129
- const cssContent$1 = declaration.node.quasi.quasis[0].value.raw;
130
- addProcessedDeclaration(declaration, cssContent$1);
129
+ const cssContent = declaration.node.quasi.quasis[0].value.raw;
130
+ addProcessedDeclaration(declaration, cssContent);
131
131
  }
132
132
  for (const declaration of declarations) {
133
133
  if (!declaration.hasInterpolations) continue;
134
134
  const { quasis, expressions } = declaration.node.quasi;
135
- let cssContent$1 = "";
135
+ let cssContent = "";
136
136
  let allResolved = true;
137
137
  for (let i = 0; i < quasis.length; i++) {
138
- cssContent$1 += quasis[i].value.raw;
138
+ cssContent += quasis[i].value.raw;
139
139
  if (i < expressions.length) {
140
140
  const expression = expressions[i];
141
141
  if (expression.type !== "Identifier") {
@@ -148,10 +148,10 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
148
148
  allResolved = false;
149
149
  break;
150
150
  }
151
- cssContent$1 += resolvedValue;
151
+ cssContent += resolvedValue;
152
152
  }
153
153
  }
154
- if (allResolved) addProcessedDeclaration(declaration, cssContent$1);
154
+ if (allResolved) addProcessedDeclaration(declaration, cssContent);
155
155
  }
156
156
  if (replacements.length === 0) return {
157
157
  transformedCode: code,
@@ -164,7 +164,7 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
164
164
  for (const { start, end, className } of replacements) transformedCode = `${transformedCode.slice(0, start)}'${className}'${transformedCode.slice(end)}`;
165
165
  cssExtractions.sort((a, b) => a.sourcePosition - b.sourcePosition);
166
166
  const cssBlocks = [];
167
- for (const { className, cssContent: cssContent$1 } of cssExtractions) if (cssContent$1 !== "") cssBlocks.push(`.${className} {\n ${cssContent$1}\n}`);
167
+ for (const { className, cssContent } of cssExtractions) if (cssContent !== "") cssBlocks.push(`.${className} {\n ${cssContent}\n}`);
168
168
  const cssContent = cssBlocks.join("\n\n");
169
169
  return {
170
170
  transformedCode,
@@ -203,7 +203,7 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
203
203
  const cssModuleId = `${cleanId}.${hashText(cssContent)}.css`;
204
204
  extractedCssPerFile.set(cssModuleId, cssContent);
205
205
  const importStatements = [];
206
- for (const id$1 of modulesWithSideEffects) importStatements.push(`import ${JSON.stringify(id$1)};\n`);
206
+ for (const id of modulesWithSideEffects) importStatements.push(`import ${JSON.stringify(id)};\n`);
207
207
  importStatements.push(`import ${JSON.stringify(cssModuleId)}\n;`);
208
208
  return `${importStatements.join("")}${transformedCode}`;
209
209
  }
package/index.d.ts CHANGED
@@ -14,7 +14,4 @@
14
14
  * const myClass = 'css-a1b2c3d4';
15
15
  * ```
16
16
  */
17
- export function css(
18
- strings: TemplateStringsArray,
19
- ...expressions: Array<string | number>
20
- ): string;
17
+ export function css(strings: TemplateStringsArray, ...expressions: Array<string | number>): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecij",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Rolldown and Vite plugin to Extract CSS-in-JS",
5
5
  "keywords": [
6
6
  "css-in-js"
@@ -9,14 +9,19 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/nstepien/ecij/issues"
11
11
  },
12
+ "license": "MIT",
13
+ "author": "Nicolas Stepien",
12
14
  "repository": {
13
15
  "type": "git",
14
16
  "url": "git+https://github.com/nstepien/ecij.git"
15
17
  },
16
- "license": "MIT",
17
- "author": "Nicolas Stepien",
18
+ "files": [
19
+ "dist",
20
+ "index.d.ts"
21
+ ],
18
22
  "type": "module",
19
23
  "sideEffects": false,
24
+ "main": "index.js",
20
25
  "exports": {
21
26
  ".": {
22
27
  "types": "./index.d.ts",
@@ -27,32 +32,23 @@
27
32
  "default": "./dist/index.js"
28
33
  }
29
34
  },
30
- "main": "index.js",
31
- "files": [
32
- "dist",
33
- "index.d.ts"
34
- ],
35
35
  "scripts": {
36
36
  "build": "rolldown -c",
37
- "format": "prettier --write .",
38
- "format:check": "prettier --check .",
37
+ "format": "oxfmt",
38
+ "format:check": "oxfmt --check",
39
39
  "typecheck": "tsc --build",
40
40
  "test": "vitest run",
41
41
  "test:coverage": "vitest run --coverage"
42
42
  },
43
- "dependencies": {
44
- "@rolldown/pluginutils": "^1.0.0-beta.53",
45
- "oxc-parser": "^0.102.0"
46
- },
47
43
  "devDependencies": {
48
- "@types/node": "^24.10.1",
49
- "@vitest/coverage-v8": "^4.0.15",
50
- "prettier": "^3.7.4",
51
- "rolldown": "^1.0.0-beta.53",
52
- "rolldown-plugin-dts": "^0.18.3",
44
+ "@types/node": "^25.3.2",
45
+ "@vitest/coverage-v8": "^4.0.18",
46
+ "oxfmt": "^0.35.0",
47
+ "rolldown": "1.0.0-rc.5",
48
+ "rolldown-plugin-dts": "^0.22.2",
53
49
  "typescript": "^5.9.3",
54
- "vite": "npm:rolldown-vite@^7.2.10",
55
- "vitest": "^4.0.15"
50
+ "vite": "^8.0.0-beta.16",
51
+ "vitest": "^4.0.18"
56
52
  },
57
53
  "overrides": {
58
54
  "vite": "$vite"