@unocss/webpack 0.44.7 → 0.45.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
@@ -42,7 +42,10 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
42
42
  rawConfig = result.config;
43
43
  uno.setConfig(rawConfig);
44
44
  uno.config.envMode = "dev";
45
- rollupFilter = pluginutils.createFilter(rawConfig.include || defaultInclude, rawConfig.exclude || defaultExclude);
45
+ rollupFilter = pluginutils.createFilter(
46
+ rawConfig.include || defaultInclude,
47
+ rawConfig.exclude || defaultExclude
48
+ );
46
49
  tokens.clear();
47
50
  await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
48
51
  invalidate();
@@ -178,6 +181,9 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
178
181
  function getPath(id) {
179
182
  return id.replace(/\?.*$/, "");
180
183
  }
184
+ function isCssId(id) {
185
+ return core.cssIdRE.test(id);
186
+ }
181
187
 
182
188
  const PLUGIN_NAME = "unocss:webpack";
183
189
  const UPDATE_DEBOUNCE = 10;
@@ -195,7 +201,9 @@ function WebpackPlugin(configOrPath, defaults) {
195
201
  });
196
202
  const nonPreTransformers = ctx.uno.config.transformers?.filter((i) => i.enforce !== "pre");
197
203
  if (nonPreTransformers?.length) {
198
- console.warn('[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n"));
204
+ console.warn(
205
+ '[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n")
206
+ );
199
207
  }
200
208
  const tasks = [];
201
209
  const entries = /* @__PURE__ */ new Set();
@@ -208,6 +216,8 @@ function WebpackPlugin(configOrPath, defaults) {
208
216
  },
209
217
  async transform(code, id) {
210
218
  const result = await applyTransformers(ctx, code, id, "pre");
219
+ if (isCssId(id))
220
+ return result;
211
221
  if (result == null)
212
222
  tasks.push(extract(code, id));
213
223
  else
@@ -216,6 +226,8 @@ function WebpackPlugin(configOrPath, defaults) {
216
226
  },
217
227
  resolveId(id) {
218
228
  const entry = resolveId(id);
229
+ if (entry === id)
230
+ return;
219
231
  if (entry) {
220
232
  let query = "";
221
233
  const queryIndex = id.indexOf("?");
@@ -263,10 +275,15 @@ function WebpackPlugin(configOrPath, defaults) {
263
275
  });
264
276
  }
265
277
  };
278
+ let lastTokenSize = tokens.size;
266
279
  async function updateModules() {
267
280
  if (!plugin.__vfsModules)
268
281
  return;
282
+ await Promise.all(tasks);
269
283
  const result = await uno.generate(tokens);
284
+ if (lastTokenSize === tokens.size)
285
+ return;
286
+ lastTokenSize = tokens.size;
270
287
  Array.from(plugin.__vfsModules).forEach((id) => {
271
288
  const path = id.slice(plugin.__virtualModulePrefix.length).replace(/\\/g, "/");
272
289
  const layer = resolveLayer(path);
package/dist/index.mjs CHANGED
@@ -32,7 +32,10 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = [], res
32
32
  rawConfig = result.config;
33
33
  uno.setConfig(rawConfig);
34
34
  uno.config.envMode = "dev";
35
- rollupFilter = createFilter(rawConfig.include || defaultInclude, rawConfig.exclude || defaultExclude);
35
+ rollupFilter = createFilter(
36
+ rawConfig.include || defaultInclude,
37
+ rawConfig.exclude || defaultExclude
38
+ );
36
39
  tokens.clear();
37
40
  await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
38
41
  invalidate();
@@ -168,6 +171,9 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
168
171
  function getPath(id) {
169
172
  return id.replace(/\?.*$/, "");
170
173
  }
174
+ function isCssId(id) {
175
+ return cssIdRE.test(id);
176
+ }
171
177
 
172
178
  const PLUGIN_NAME = "unocss:webpack";
173
179
  const UPDATE_DEBOUNCE = 10;
@@ -185,7 +191,9 @@ function WebpackPlugin(configOrPath, defaults) {
185
191
  });
186
192
  const nonPreTransformers = ctx.uno.config.transformers?.filter((i) => i.enforce !== "pre");
187
193
  if (nonPreTransformers?.length) {
188
- console.warn('[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n"));
194
+ console.warn(
195
+ '[unocss] webpack integration only supports "pre" enforce transformers currently.the following transformers will be ignored\n' + nonPreTransformers.map((i) => ` - ${i.name}`).join("\n")
196
+ );
189
197
  }
190
198
  const tasks = [];
191
199
  const entries = /* @__PURE__ */ new Set();
@@ -198,6 +206,8 @@ function WebpackPlugin(configOrPath, defaults) {
198
206
  },
199
207
  async transform(code, id) {
200
208
  const result = await applyTransformers(ctx, code, id, "pre");
209
+ if (isCssId(id))
210
+ return result;
201
211
  if (result == null)
202
212
  tasks.push(extract(code, id));
203
213
  else
@@ -206,6 +216,8 @@ function WebpackPlugin(configOrPath, defaults) {
206
216
  },
207
217
  resolveId(id) {
208
218
  const entry = resolveId(id);
219
+ if (entry === id)
220
+ return;
209
221
  if (entry) {
210
222
  let query = "";
211
223
  const queryIndex = id.indexOf("?");
@@ -253,10 +265,15 @@ function WebpackPlugin(configOrPath, defaults) {
253
265
  });
254
266
  }
255
267
  };
268
+ let lastTokenSize = tokens.size;
256
269
  async function updateModules() {
257
270
  if (!plugin.__vfsModules)
258
271
  return;
272
+ await Promise.all(tasks);
259
273
  const result = await uno.generate(tokens);
274
+ if (lastTokenSize === tokens.size)
275
+ return;
276
+ lastTokenSize = tokens.size;
260
277
  Array.from(plugin.__vfsModules).forEach((id) => {
261
278
  const path = id.slice(plugin.__virtualModulePrefix.length).replace(/\\/g, "/");
262
279
  const layer = resolveLayer(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/webpack",
3
- "version": "0.44.7",
3
+ "version": "0.45.4",
4
4
  "description": "The Webpack plugin for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -38,16 +38,16 @@
38
38
  "dependencies": {
39
39
  "@ampproject/remapping": "^2.2.0",
40
40
  "@rollup/pluginutils": "^4.2.1",
41
- "@unocss/config": "0.44.7",
42
- "@unocss/core": "0.44.7",
41
+ "@unocss/config": "0.45.4",
42
+ "@unocss/core": "0.45.4",
43
43
  "magic-string": "^0.26.2",
44
- "unplugin": "^0.7.0",
44
+ "unplugin": "^0.8.1",
45
45
  "webpack-sources": "^3.2.3"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/webpack": "^5.28.0",
49
49
  "@types/webpack-sources": "^3.2.0",
50
- "webpack": "^5.73.0"
50
+ "webpack": "^5.74.0"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "unbuild",