@animus-ui/vite-plugin 0.1.30 → 0.1.31

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
@@ -96,6 +96,21 @@ supplies either `cspHash` or a per-request nonce. Worked App Router and Pages
96
96
  Router examples live in the
97
97
  [`@animus-ui/next-plugin` README](https://github.com/codecaaron/animus/tree/main/packages/next-plugin#appearance-bootstrap-no-fouc-color-mode).
98
98
 
99
+ ## MDX
100
+
101
+ Animus reads each `.mdx` file as the JSX it renders: its imports, exports,
102
+ tags, props and `{expressions}`. It needs no MDX compiler. A component a tag
103
+ names, or one your provider maps markdown to (`# x` → your heading), counts
104
+ as rendered. Markdown and code examples render nothing.
105
+
106
+ MDX renders components; it declares no styles. Animus reports any reference
107
+ to its builder in an `.mdx` file as `SOURCE_MDX_STYLE_DECLARATION`, and a
108
+ strict build fails on it. That covers any import from `@animus-ui/system`,
109
+ and any member named like a builder method (`styles`, `variant`,
110
+ `compound`, `states`, `system`, `props`, `extend`, `asElement`,
111
+ `asComponent`, `asClass`), read, called or destructured. So `{Box.styles}`
112
+ is reported too. Declare components in `.ts` or `.tsx` files and import them.
113
+
99
114
  ## Important
100
115
 
101
116
  - Do **not** add React resolve aliases to `vite.config.ts` — they break the extraction transform pipeline
@@ -1,8 +1,11 @@
1
1
  import type { PluginContext } from './context';
2
2
  import type { HostResolve } from '@animus-ui/extract/pipeline';
3
3
  /**
4
- * `resolveSpecifier` maps a specifier to an absolute id. `emitAsset` is
5
- * present in build only, where `asset()` files become Rollup assets.
4
+ * The file an `asset()` specifier names when its package's exports leave it
5
+ * out, as a source kit's often do: the subpath in the package Vite's
6
+ * resolver reached, so an alias keeps its target. Any other resolver
7
+ * failure, or a refusal naming no absolute package directory, is rethrown.
6
8
  */
9
+ export declare function unexportedAssetFile(error: Error): string | null;
7
10
  export declare function runBuildStart(ctx: PluginContext, resolveSpecifier: HostResolve, emitAsset?: (fileName: string, source: Uint8Array) => string): Promise<void>;
8
11
  //# sourceMappingURL=build-start.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;;GAGG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,WAAW,EAC7B,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,CA2If"}
1
+ {"version":3,"file":"build-start.d.ts","sourceRoot":"","sources":["../src/build-start.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAa/D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAY/D;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,WAAW,EAC7B,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,CA4If"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,cAAc,GACrB,IAAI,CAuEN"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,cAAc,GACrB,IAAI,CA4EN"}
package/dist/index.cjs CHANGED
@@ -94,6 +94,24 @@ function sweepAbandonedCopyDirs(copyRoot) {
94
94
  * `resolveSpecifier` maps a specifier to an absolute id. `emitAsset` is
95
95
  * present in build only, where `asset()` files become Rollup assets.
96
96
  */
97
+ /** Vite's resolver refuses a file its package's exports leave out, naming
98
+ * the package it reached, after any alias. The message ends with that
99
+ * directory twice, and both must agree: a path can itself hold the
100
+ * delimiter text. */
101
+ const NOT_EXPORTED = /"\.\/([^"]+)" is not exported under the conditions \[[^\]]*\] from package (.+) \(see exports field in \2\/package\.json\)\.?$/;
102
+ /**
103
+ * The file an `asset()` specifier names when its package's exports leave it
104
+ * out, as a source kit's often do: the subpath in the package Vite's
105
+ * resolver reached, so an alias keeps its target. Any other resolver
106
+ * failure, or a refusal naming no absolute package directory, is rethrown.
107
+ */
108
+ function unexportedAssetFile(error) {
109
+ const refused = NOT_EXPORTED.exec(String(error?.message));
110
+ const packageDir = refused?.[2];
111
+ if (packageDir === void 0 || !(0, path.isAbsolute)(packageDir) || !(0, fs.existsSync)((0, path.join)(packageDir, "package.json"))) throw error;
112
+ const file = (0, path.join)(packageDir, refused[1]);
113
+ return (0, fs.existsSync)(file) ? file : null;
114
+ }
97
115
  async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
98
116
  ctx.assetPassComplete = false;
99
117
  ctx.assetUrlBySpecifier.clear();
@@ -118,7 +136,7 @@ async function runBuildStart(ctx, resolveSpecifier, emitAsset) {
118
136
  ctx.assetSourceBySpecifier.clear();
119
137
  if (ctx.assetCopyDir !== null) sweepAbandonedCopyDirs((0, path.dirname)(ctx.assetCopyDir));
120
138
  for (const specifier of assetSpecifiers) {
121
- const resolvedPath = await resolveSpecifier(specifier);
139
+ const resolvedPath = await resolveSpecifier(specifier).catch(unexportedAssetFile);
122
140
  if (!resolvedPath) {
123
141
  ctx.assetFallback(specifier, `[animus-extract] unresolvable asset() specifier: ${specifier}`);
124
142
  continue;
@@ -191,6 +209,7 @@ function applyResolvedConfig(ctx, config) {
191
209
  const pairs = [];
192
210
  for (const entry of config.resolve.alias) {
193
211
  if (entry.find instanceof RegExp) continue;
212
+ if (!(0, path.isAbsolute)(entry.replacement) && !entry.replacement.startsWith(".")) continue;
194
213
  pairs.push({
195
214
  pattern: entry.find,
196
215
  target: entry.replacement,
@@ -1001,7 +1020,7 @@ async function transformSource(ctx, code, requestId) {
1001
1020
  let detectionFailed = false;
1002
1021
  if (!ctx.storedManifest.files[relativePath]?.length) {
1003
1022
  const session = ctx.session;
1004
- if (!ctx.isProd && session !== null && !session.heldSources.has(relativePath)) {
1023
+ if (!ctx.isProd && session !== null && !session.heldSources.has(relativePath) && (isExternalPkg || ctx.extensionsSet.has((0, path.extname)(id)) && !ctx.excludeMatcher.matches(id, relativePath))) {
1005
1024
  let outcomes = [];
1006
1025
  try {
1007
1026
  outcomes = await ctx.submitChanges(changesOf("create", id));
package/dist/index.d.ts CHANGED
@@ -26,8 +26,9 @@ export interface AnimusExtractOptions {
26
26
  */
27
27
  exclude?: string[];
28
28
  /**
29
- * Replaces the default extension list entirely. `.mdx` needs the
30
- * `@mdx-js/mdx` peer, or those files warn once and are skipped.
29
+ * Replaces the default extension list entirely. `.mdx` is read for the
30
+ * components it renders, with no MDX compiler; any reference to the
31
+ * builder in it is an error (see the README's MDX section).
31
32
  */
32
33
  extensions?: string[];
33
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAEhB,eAAe,EAChB,MAAM,6BA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AC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;OAGG;IACH,mBAAmB,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD;AAMD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAkInE;eAEc,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"rediscovery.d.ts","sourceRoot":"","sources":["../src/rediscovery.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AAUrC;qEACqE;AACrE,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,GACjB,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAS3C;AAuED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,eAAe,EAAE,CAAC,CAyB5B"}
1
+ {"version":3,"file":"rediscovery.d.ts","sourceRoot":"","sources":["../src/rediscovery.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AAUrC;qEACqE;AACrE,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,GACjB,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAS3C;AAwED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,eAAe,EAAE,CAAC,CAyB5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,WAAW,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;4DAC4D;AAC5D,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,GAAG,CAAC,MAAM,CAAC,CAkBb;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC,CAqJ7C"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,WAAW,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;4DAC4D;AAC5D,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,GAAG,CAAC,MAAM,CAAC,CAkBb;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC,CA0J7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@animus-ui/vite-plugin",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "Animus static CSS extraction Vite plugin",
5
5
  "keywords": [
6
6
  "animus",
@@ -39,22 +39,16 @@
39
39
  "compile": "bun check"
40
40
  },
41
41
  "dependencies": {
42
- "@animus-ui/extract": "0.1.30",
42
+ "@animus-ui/extract": "0.1.31",
43
43
  "browserslist": "^4.28.8",
44
44
  "lightningcss": "^1.33.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@animus-ui/assertions": "0.1.30"
47
+ "@animus-ui/assertions": "0.1.31"
48
48
  },
49
49
  "peerDependencies": {
50
- "@mdx-js/mdx": "^3.0.0",
51
50
  "vite": ">=8 <9"
52
51
  },
53
- "peerDependenciesMeta": {
54
- "@mdx-js/mdx": {
55
- "optional": true
56
- }
57
- },
58
52
  "engines": {
59
53
  "node": ">=22.12.0"
60
54
  }