ecij 0.4.0 → 0.4.1

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 +12 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ function hashText(text) {
14
14
  }
15
15
  function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_FILE_REGEX], classPrefix = "css-" } = {}) {
16
16
  const parsedFileInfoCache = /* @__PURE__ */ new Map();
17
+ const stylesheetImportPerFile = /* @__PURE__ */ new Map();
17
18
  const extractedCssPerFile = /* @__PURE__ */ new Map();
18
19
  /**
19
20
  * Parses a file and extracts all relevant information in a single pass
@@ -95,17 +96,18 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
95
96
  const { declarations, localIdentifiers, importedIdentifiers } = await parseFile(context, filePath, code);
96
97
  const cssExtractions = [];
97
98
  const replacements = [];
98
- const modulesWithSideEffects = /* @__PURE__ */ new Set();
99
+ const stylesheetDependencies = /* @__PURE__ */ new Set();
99
100
  async function resolveValue(identifierName) {
100
101
  if (localIdentifiers.has(identifierName)) return localIdentifiers.get(identifierName);
101
102
  if (importedIdentifiers.has(identifierName)) {
102
103
  const { source, imported } = importedIdentifiers.get(identifierName);
103
104
  const resolvedId = await context.resolve(source, filePath);
104
105
  if (resolvedId != null) {
106
+ await context.load(resolvedId);
105
107
  const { id } = resolvedId;
106
- const { declarations, exportNameToValueMap } = await parseFile(context, id);
108
+ const { exportNameToValueMap } = await parseFile(context, id);
107
109
  if (exportNameToValueMap.has(imported)) {
108
- if (declarations.length !== 0) modulesWithSideEffects.add(id);
110
+ if (stylesheetImportPerFile.has(id)) stylesheetDependencies.add(stylesheetImportPerFile.get(id));
109
111
  return exportNameToValueMap.get(imported);
110
112
  }
111
113
  }
@@ -157,7 +159,7 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
157
159
  transformedCode: code,
158
160
  hasExtractions: false,
159
161
  cssContent: "",
160
- modulesWithSideEffects
162
+ stylesheetDependencies
161
163
  };
162
164
  replacements.sort((a, b) => b.start - a.start);
163
165
  let transformedCode = code;
@@ -170,13 +172,14 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
170
172
  transformedCode,
171
173
  hasExtractions: true,
172
174
  cssContent,
173
- modulesWithSideEffects
175
+ stylesheetDependencies
174
176
  };
175
177
  }
176
178
  return {
177
179
  name: "ecij",
178
180
  buildEnd() {
179
181
  parsedFileInfoCache.clear();
182
+ stylesheetImportPerFile.clear();
180
183
  extractedCssPerFile.clear();
181
184
  },
182
185
  resolveId(id) {
@@ -197,14 +200,15 @@ function ecij({ include = JS_TS_FILE_REGEX, exclude = [NODE_MODULES_REGEX, D_TS_
197
200
  if (!code.includes("ecij")) return null;
198
201
  const queryIndex = id.indexOf("?");
199
202
  const cleanId = queryIndex === -1 ? id : id.slice(0, queryIndex);
200
- const { transformedCode, hasExtractions, cssContent, modulesWithSideEffects } = await extractCssFromCode(this, code, cleanId);
203
+ const { transformedCode, hasExtractions, cssContent, stylesheetDependencies } = await extractCssFromCode(this, code, cleanId);
201
204
  if (!hasExtractions) return null;
202
205
  if (cssContent === "") return transformedCode;
203
206
  const cssModuleId = `${cleanId}.${hashText(cssContent)}.css`;
204
207
  extractedCssPerFile.set(cssModuleId, cssContent);
208
+ stylesheetImportPerFile.set(id, cssModuleId);
205
209
  const importStatements = [];
206
- for (const id of modulesWithSideEffects) importStatements.push(`import ${JSON.stringify(id)};\n`);
207
- importStatements.push(`import ${JSON.stringify(cssModuleId)}\n;`);
210
+ for (const id of stylesheetDependencies) importStatements.push(`import ${JSON.stringify(id)};\n`);
211
+ importStatements.push(`import ${JSON.stringify(cssModuleId)};\n`);
208
212
  return `${importStatements.join("")}${transformedCode}`;
209
213
  }
210
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecij",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Rolldown and Vite plugin to Extract CSS-in-JS",
5
5
  "keywords": [
6
6
  "css-in-js"
@@ -44,7 +44,7 @@
44
44
  "@types/node": "^25.3.2",
45
45
  "@vitest/coverage-v8": "^4.0.18",
46
46
  "oxfmt": "^0.35.0",
47
- "rolldown": "1.0.0-rc.5",
47
+ "rolldown": "^1.0.0-rc.6",
48
48
  "rolldown-plugin-dts": "^0.22.2",
49
49
  "typescript": "^5.9.3",
50
50
  "vite": "^8.0.0-beta.16",