@plumeria/unplugin 18.3.0 → 18.3.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/README.md +2 -39
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -196,48 +196,11 @@ If the two disagree, the prop type-checks but is never compiled away. [`@plumeri
196
196
 
197
197
  `@plumeria/unplugin` provides HMR optimized for each bundler in development mode (dev server).
198
198
 
199
- - **Vite / Farm / Webpack / Rspack**: The plugin extracts styles as CSS modules, enabling seamless updates via hot reloading.
199
+ - **Vite / Farm / Webpack / Rspack**: The extracted stylesheet is served as a virtual module and reloaded only when its content actually changed, so a style edit updates in place without a repaint.
200
200
 
201
201
  ## Testing
202
202
 
203
- `@plumeria/unplugin/factory` exposes the compiler behind every bundler entry as a plain function. Give it a source string and it hands back the rewritten code, with the stylesheet available from `resolveId` and `load`:
204
-
205
- ```js
206
- // compile.test.js
207
- const { unpluginFactory } = require('@plumeria/unplugin/factory');
208
-
209
- const compile = async (source) => {
210
- const plugin = unpluginFactory(undefined, { framework: 'vite' });
211
- const result = await plugin.transform.call(
212
- { addWatchFile: () => {} },
213
- source,
214
- `${__dirname}/fixture.tsx`,
215
- );
216
- const code = typeof result === 'string' ? result : (result?.code ?? '');
217
- const cssId = code.match(/import "([^"]*\.zero\.css)"/)?.[1];
218
- const resolved = await plugin.resolveId?.call({}, cssId);
219
- const loaded = await plugin.load?.call({}, resolved?.id ?? resolved);
220
- return { code, css: typeof loaded === 'string' ? loaded : (loaded?.code ?? '') };
221
- };
222
-
223
- test('two properties become two atoms', async () => {
224
- const { code, css } = await compile(`
225
- import * as css from '@plumeria/core';
226
- const styles = css.create({ box: { padding: 16, color: 'red' } });
227
- export const A = () => <div classStyle={styles.box} />;
228
- `);
229
-
230
- expect(code).toMatch(/className=\{"\S+ \S+"\}/);
231
- expect(css).toContain('padding: 16px');
232
- expect(css).toContain('color: red');
233
- });
234
- ```
235
-
236
- No bundler, no DOM, and no runtime resolution of `@plumeria/core` is involved, so Jest, Vitest and `node:test` all run it as it stands. The bundler entries reach `unplugin` itself, which is ESM and cannot be required from a CommonJS runner; this subpath skips them.
237
-
238
- Read the class names out of the returned code rather than hard-coding them. An atomic class name is one property–value pair, hashed, so a list spelled out in a test breaks the next time a property is added to the style.
239
-
240
- See [Testing](https://plumeria.dev/docs/testing) for the layer this belongs to, and the two it does not cover.
203
+ `@plumeria/unplugin/factory` exposes the plugin behind every bundler entry, so a test can drive its `transform`, `resolveId` and `load` hooks directly and assert on the compiled output with no bundler in between. See [Testing](https://plumeria.dev/docs/testing) for the example, and for the component behavior and rendered-page checks that complement it.
241
204
 
242
205
  ## API Stability
243
206
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/unplugin",
3
- "version": "18.3.0",
3
+ "version": "18.3.1",
4
4
  "description": "Universal Plumeria plugin for various build tools",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -94,7 +94,7 @@
94
94
  "dependencies": {
95
95
  "@rollup/pluginutils": "^5.4.0",
96
96
  "unplugin": "^3.0.0",
97
- "@plumeria/utils": "^18.3.0"
97
+ "@plumeria/utils": "^18.3.1"
98
98
  },
99
99
  "devDependencies": {
100
100
  "@swc/core": "1.15.47",