@animus-ui/next-plugin 0.1.32 → 0.1.37
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 +98 -0
- package/dist/font-preloads.cjs +42 -0
- package/dist/font-preloads.d.ts +13 -0
- package/dist/font-preloads.d.ts.map +1 -0
- package/dist/font-preloads.mjs +38 -0
- package/dist/index.cjs +89 -36
- package/dist/index.mjs +75 -22
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/quarantine.d.ts +7 -0
- package/dist/quarantine.d.ts.map +1 -0
- package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
- package/dist/{turbopack-config-3jtLDAIM.mjs → turbopack-config-BOUPGkmi.mjs} +3 -2
- package/dist/{turbopack-config-BoNfzhNu.cjs → turbopack-config-W5eoa_xN.cjs} +2 -1
- package/dist/turbopack-config.d.ts.map +1 -1
- package/dist/turbopack-loader.cjs +6 -27
- package/dist/turbopack-loader.d.ts +1 -1
- package/dist/turbopack-loader.d.ts.map +1 -1
- package/dist/turbopack-loader.mjs +5 -5
- package/dist/types.d.ts +16 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/with-animus.d.ts +1 -0
- package/dist/with-animus.d.ts.map +1 -1
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -71,6 +71,47 @@ export default withAnimus({
|
|
|
71
71
|
Under webpack (`next dev` / `next build` on 15, or `--webpack` on 16) the
|
|
72
72
|
plugin behaves exactly as before.
|
|
73
73
|
|
|
74
|
+
## Third-party stylesheets
|
|
75
|
+
|
|
76
|
+
A library's plain CSS outside any `@layer` beats every Animus layer. With
|
|
77
|
+
`quarantine`, [`@animus-ui/layergate`](../layergate/README.md) loads it into
|
|
78
|
+
`anm-vendor`, a layer below all of Animus's, so Animus's styles win and the
|
|
79
|
+
library's still apply where Animus sets nothing:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm install -D @animus-ui/layergate
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
export default withAnimus({
|
|
87
|
+
system: './src/ds.ts',
|
|
88
|
+
quarantine: {
|
|
89
|
+
sheets: ['react-grid-layout/css/styles.css'], // delivered ahead of Animus's own CSS
|
|
90
|
+
dependencies: ['react-datepicker'], // CSS these packages' modules import
|
|
91
|
+
optOut: [], // exact files whose own rules stay unlayered
|
|
92
|
+
},
|
|
93
|
+
})(nextConfig);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
It needs webpack: `next dev` and `next build` on Next 15, `--webpack` on
|
|
97
|
+
Next 16. Turbopack runs no loader on the stylesheets a stylesheet imports,
|
|
98
|
+
so with `quarantine` set any Turbopack run fails config loading, whatever
|
|
99
|
+
the `turbopack` option says. Next marks a Turbopack run by setting
|
|
100
|
+
`TURBOPACK`, so Animus refuses whenever that variable is set, even empty.
|
|
101
|
+
The converse: a `TURBOPACK` inherited from the environment also refuses a
|
|
102
|
+
webpack build of Next 15, loudly, so clear stale values in CI.
|
|
103
|
+
|
|
104
|
+
Vendor stylesheets layergate finishes are not kept in webpack's persistent
|
|
105
|
+
cache, so a warm rebuild finishes them again: about 118 ms per 200 vendor
|
|
106
|
+
sheets in a synthetic measurement.
|
|
107
|
+
|
|
108
|
+
`sheets` arrive at the head of Animus's own stylesheet, on every page.
|
|
109
|
+
`!important` declarations and animations still win, and are reported. App
|
|
110
|
+
CSS keeps its own rules unlayered; where it imports a vendor file, that file
|
|
111
|
+
is layered. CSS Modules are left alone. A remote `@import` in a vendor
|
|
112
|
+
stylesheet is an error: vendor the sheet locally, or opt the file out if
|
|
113
|
+
unlayered is acceptable.
|
|
114
|
+
|
|
74
115
|
## Appearance bootstrap (no-FOUC color mode)
|
|
75
116
|
|
|
76
117
|
Optional. Restores a persisted color mode before first paint with zero runtime
|
|
@@ -128,6 +169,63 @@ Two rules either way:
|
|
|
128
169
|
you add to the script tag. The full CSP footguns are documented in the
|
|
129
170
|
[`@animus-ui/vite-plugin` README](https://github.com/codecaaron/animus/tree/main/packages/vite-plugin#content-security-policy).
|
|
130
171
|
|
|
172
|
+
## Font preloads
|
|
173
|
+
|
|
174
|
+
A font face declared with `preload: true` can start loading before the
|
|
175
|
+
stylesheet's `@font-face` applies. The plugin injects nothing into the
|
|
176
|
+
document, so render the component that delivers it. It renders nothing when
|
|
177
|
+
no face preloads.
|
|
178
|
+
|
|
179
|
+
`fontPreloads` in `withAnimus`'s options selects the faces that preload in
|
|
180
|
+
place of their `preload` flags, for an app that renders only some of a
|
|
181
|
+
system's faces: a family name selects every face of the family, and
|
|
182
|
+
`{ family, weight?, style? }` the faces whose declared weight contains
|
|
183
|
+
`weight` and whose style is `style` (`'normal'` when omitted). `[]` preloads
|
|
184
|
+
none. An entry no face matches reports `animus.style.font-preload-unmatched`;
|
|
185
|
+
a malformed one, such as a weight range, `animus.style.font-preload-invalid`.
|
|
186
|
+
|
|
187
|
+
**App Router:** render `AnimusFontPreloads` in the root layout. React hoists
|
|
188
|
+
each preload into `<head>` ahead of the stylesheets, and dedupes it by href,
|
|
189
|
+
against `next/font` too.
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
// app/layout.tsx
|
|
193
|
+
import { AnimusFontPreloads } from '@animus-ui/next-plugin/font-preloads';
|
|
194
|
+
|
|
195
|
+
export default function RootLayout({
|
|
196
|
+
children,
|
|
197
|
+
}: {
|
|
198
|
+
children: React.ReactNode;
|
|
199
|
+
}) {
|
|
200
|
+
return (
|
|
201
|
+
<html lang="en">
|
|
202
|
+
<body>
|
|
203
|
+
<AnimusFontPreloads />
|
|
204
|
+
{children}
|
|
205
|
+
</body>
|
|
206
|
+
</html>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Pages Router:** render `AnimusFontPreloadLinks` inside `<Head>` in
|
|
212
|
+
`pages/_document.tsx`. It renders plain `<link>` tags, which any React
|
|
213
|
+
version renders.
|
|
214
|
+
|
|
215
|
+
Each preload names the URL the stylesheet's `url()` loads (the hashed
|
|
216
|
+
`/_next/static/media/…` file, under webpack and Turbopack, in build and in
|
|
217
|
+
development), so the browser fetches the file once. `withAnimus` adds this
|
|
218
|
+
package to `transpilePackages`, so Next bundles the component and resolves
|
|
219
|
+
the module it reads. Nothing detects a layout that never renders the
|
|
220
|
+
component: the faces then load when the stylesheet applies, as without
|
|
221
|
+
`preload`.
|
|
222
|
+
|
|
223
|
+
A preload competes with the critical CSS and JavaScript for first paint, so
|
|
224
|
+
preload WOFF2 and only the faces the first screen needs: a large TrueType
|
|
225
|
+
file can delay first paint by seconds on a slow link. A preloaded file that
|
|
226
|
+
is not WOFF2 or WOFF, or an `asset()` file over 150 KB, reports
|
|
227
|
+
`animus.style.font-face-preload-costly`.
|
|
228
|
+
|
|
131
229
|
## MDX
|
|
132
230
|
|
|
133
231
|
Animus reads each `.mdx` file as the JSX it renders: its imports, exports,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_dom = require("react-dom");
|
|
5
|
+
let virtual_animus_font_preloads = require("virtual:animus/font-preloads");
|
|
6
|
+
virtual_animus_font_preloads = require_rolldown_runtime.__toESM(virtual_animus_font_preloads);
|
|
7
|
+
//#region src/font-preloads.ts
|
|
8
|
+
/**
|
|
9
|
+
* The font preloads the system's faces ask for (`preload: true`, or the
|
|
10
|
+
* `fontPreloads` option), rendered into the document. Server-only; it
|
|
11
|
+
* imports neither the engine nor Node.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* App Router: render it in the root layout. React hoists each preload into
|
|
15
|
+
* `<head>` ahead of the stylesheets and dedupes it by href, against
|
|
16
|
+
* `next/font` too. Renders nothing; a no-op when no face preloads.
|
|
17
|
+
*/
|
|
18
|
+
function AnimusFontPreloads() {
|
|
19
|
+
for (const { href, type } of virtual_animus_font_preloads.default) (0, react_dom.preload)(href, {
|
|
20
|
+
as: "font",
|
|
21
|
+
type,
|
|
22
|
+
crossOrigin: ""
|
|
23
|
+
});
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pages Router: render it inside `<Head>` in `pages/_document`, as plain
|
|
28
|
+
* `<link>` tags any React version renders. Empty when no face preloads.
|
|
29
|
+
*/
|
|
30
|
+
function AnimusFontPreloadLinks() {
|
|
31
|
+
return (0, react.createElement)(react.Fragment, null, ...virtual_animus_font_preloads.default.map(({ href, type }) => (0, react.createElement)("link", {
|
|
32
|
+
key: href,
|
|
33
|
+
rel: "preload",
|
|
34
|
+
href,
|
|
35
|
+
as: "font",
|
|
36
|
+
type,
|
|
37
|
+
crossOrigin: ""
|
|
38
|
+
})));
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.AnimusFontPreloadLinks = AnimusFontPreloadLinks;
|
|
42
|
+
exports.AnimusFontPreloads = AnimusFontPreloads;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* App Router: render it in the root layout. React hoists each preload into
|
|
4
|
+
* `<head>` ahead of the stylesheets and dedupes it by href, against
|
|
5
|
+
* `next/font` too. Renders nothing; a no-op when no face preloads.
|
|
6
|
+
*/
|
|
7
|
+
export declare function AnimusFontPreloads(): null;
|
|
8
|
+
/**
|
|
9
|
+
* Pages Router: render it inside `<Head>` in `pages/_document`, as plain
|
|
10
|
+
* `<link>` tags any React version renders. Empty when no face preloads.
|
|
11
|
+
*/
|
|
12
|
+
export declare function AnimusFontPreloadLinks(): ReactElement;
|
|
13
|
+
//# sourceMappingURL=font-preloads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font-preloads.d.ts","sourceRoot":"","sources":["../src/font-preloads.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK1C;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAKzC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAerD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Fragment, createElement } from "react";
|
|
2
|
+
import { preload } from "react-dom";
|
|
3
|
+
import preloads from "virtual:animus/font-preloads";
|
|
4
|
+
//#region src/font-preloads.ts
|
|
5
|
+
/**
|
|
6
|
+
* The font preloads the system's faces ask for (`preload: true`, or the
|
|
7
|
+
* `fontPreloads` option), rendered into the document. Server-only; it
|
|
8
|
+
* imports neither the engine nor Node.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* App Router: render it in the root layout. React hoists each preload into
|
|
12
|
+
* `<head>` ahead of the stylesheets and dedupes it by href, against
|
|
13
|
+
* `next/font` too. Renders nothing; a no-op when no face preloads.
|
|
14
|
+
*/
|
|
15
|
+
function AnimusFontPreloads() {
|
|
16
|
+
for (const { href, type } of preloads) preload(href, {
|
|
17
|
+
as: "font",
|
|
18
|
+
type,
|
|
19
|
+
crossOrigin: ""
|
|
20
|
+
});
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Pages Router: render it inside `<Head>` in `pages/_document`, as plain
|
|
25
|
+
* `<link>` tags any React version renders. Empty when no face preloads.
|
|
26
|
+
*/
|
|
27
|
+
function AnimusFontPreloadLinks() {
|
|
28
|
+
return createElement(Fragment, null, ...preloads.map(({ href, type }) => createElement("link", {
|
|
29
|
+
key: href,
|
|
30
|
+
rel: "preload",
|
|
31
|
+
href,
|
|
32
|
+
as: "font",
|
|
33
|
+
type,
|
|
34
|
+
crossOrigin: ""
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AnimusFontPreloadLinks, AnimusFontPreloads };
|
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_turbopack_config = require("./turbopack-config-
|
|
2
|
+
const require_turbopack_config = require("./turbopack-config-W5eoa_xN.cjs");
|
|
3
3
|
let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
|
|
4
4
|
let _animus_ui_extract_session = require("@animus-ui/extract/session");
|
|
5
5
|
let fs = require("fs");
|
|
6
6
|
let path = require("path");
|
|
7
7
|
let url = require("url");
|
|
8
|
+
let module$1 = require("module");
|
|
8
9
|
//#region src/same-directory.ts
|
|
9
10
|
/** Whether two paths name one directory: by real path, which resolves a
|
|
10
11
|
* trailing slash, a symlink and the filesystem's own spelling, else by
|
|
11
12
|
* device and inode. */
|
|
12
13
|
function sameDirectory(a, b) {
|
|
13
|
-
const real = (path$
|
|
14
|
+
const real = (path$12) => {
|
|
14
15
|
try {
|
|
15
|
-
return fs.realpathSync.native(path$
|
|
16
|
+
return fs.realpathSync.native(path$12);
|
|
16
17
|
} catch {
|
|
17
|
-
return (0, path.resolve)(path$
|
|
18
|
+
return (0, path.resolve)(path$12);
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
if (real(a) === real(b)) return true;
|
|
@@ -93,25 +94,25 @@ function globSource(glob) {
|
|
|
93
94
|
}
|
|
94
95
|
/** What `ignored` ignores, as Watchpack decides it; nothing when unset. */
|
|
95
96
|
function ignoredMatcher(ignored) {
|
|
96
|
-
const slashed = (path$
|
|
97
|
+
const slashed = (path$6) => path$6.replace(/\\/g, "/");
|
|
97
98
|
if (ignored === void 0 || ignored === null) return () => false;
|
|
98
|
-
if (isWatchIgnoreMatcher(ignored)) return (path$
|
|
99
|
-
if (ignored instanceof RegExp) return (path$
|
|
99
|
+
if (isWatchIgnoreMatcher(ignored)) return (path$7) => Boolean(ignored(path$7));
|
|
100
|
+
if (ignored instanceof RegExp) return (path$8) => ignored.test(slashed(path$8));
|
|
100
101
|
const sources = (isWatchIgnoreString(ignored) ? [ignored] : ignored).map((entry) => entry instanceof RegExp ? entry.source : entry.length > 0 ? globSource(entry) : null).filter((source) => source !== null);
|
|
101
102
|
if (sources.length === 0) return () => false;
|
|
102
103
|
const pattern = new RegExp(sources.join("|"));
|
|
103
|
-
return (path$
|
|
104
|
+
return (path$9) => pattern.test(slashed(path$9));
|
|
104
105
|
}
|
|
105
106
|
/** Windows paths compare without case, as `path.win32.relative` does. */
|
|
106
|
-
const comparable = process.platform === "win32" ? (path$
|
|
107
|
+
const comparable = process.platform === "win32" ? (path$10) => path$10.toLowerCase() : (path$11) => path$11;
|
|
107
108
|
/** Whether a path is one of `directories` or lies under one where a kit's
|
|
108
109
|
* sources can live: never in the kit's own `node_modules` or another path
|
|
109
110
|
* ingestion excludes, which stay as the host decides. A prefix test:
|
|
110
111
|
* webpack's watcher asks for every path it watches. */
|
|
111
112
|
function withinDirectories(directories) {
|
|
112
113
|
const prefixes = directories.map((dir) => comparable(dir.endsWith(path.sep) ? dir : dir + path.sep)).sort((a, b) => b.length - a.length);
|
|
113
|
-
return (path$
|
|
114
|
-
const key = comparable(path$
|
|
114
|
+
return (path$5) => {
|
|
115
|
+
const key = comparable(path$5) + path.sep;
|
|
115
116
|
const prefix = prefixes.find((candidate) => key.startsWith(candidate));
|
|
116
117
|
return prefix !== void 0 && !(0, _animus_ui_extract_pipeline.isExcludedPackageRelativePath)(key.slice(prefix.length));
|
|
117
118
|
};
|
|
@@ -140,6 +141,8 @@ var AnimusWebpackPlugin = class {
|
|
|
140
141
|
files: /* @__PURE__ */ new Set(),
|
|
141
142
|
directories: () => false
|
|
142
143
|
};
|
|
144
|
+
/** Other files the watcher must see, by the plugins that read them. */
|
|
145
|
+
alsoWatched = [];
|
|
143
146
|
/** The webpack config Next hands its watcher, when withAnimus made it. */
|
|
144
147
|
watchedConfig;
|
|
145
148
|
/** `development` is `next dev`: an error-level diagnostic reports and the
|
|
@@ -149,6 +152,7 @@ var AnimusWebpackPlugin = class {
|
|
|
149
152
|
(0, _animus_ui_extract_pipeline.assertSupportedEngine)(options.engine);
|
|
150
153
|
this.session = new _animus_ui_extract_session.ExtractionSession(options, { build });
|
|
151
154
|
this.session.development = development;
|
|
155
|
+
this.session.writesFontPreloadsModule = true;
|
|
152
156
|
this.session.delivery = {
|
|
153
157
|
...this.session.delivery,
|
|
154
158
|
systemPropsModuleId: _animus_ui_extract_session.TURBOPACK_SYSTEM_PROPS_ID
|
|
@@ -166,6 +170,11 @@ var AnimusWebpackPlugin = class {
|
|
|
166
170
|
watchConfig(config) {
|
|
167
171
|
this.watchedConfig = config;
|
|
168
172
|
}
|
|
173
|
+
/** Makes `watchIgnored` watch the paths `watches` names too: one matcher
|
|
174
|
+
* owns the host's watch options. */
|
|
175
|
+
watchAlso(watches) {
|
|
176
|
+
this.alsoWatched.push(watches);
|
|
177
|
+
}
|
|
169
178
|
/**
|
|
170
179
|
* `watchOptions.ignored` for the host's own `ignored`: this session's epoch
|
|
171
180
|
* file stays ignored, and every file and directory the Session's watch plan
|
|
@@ -184,10 +193,10 @@ var AnimusWebpackPlugin = class {
|
|
|
184
193
|
}
|
|
185
194
|
return epochPath;
|
|
186
195
|
};
|
|
187
|
-
return (path$
|
|
188
|
-
if (path$
|
|
189
|
-
if (this.registered.files.has(path$
|
|
190
|
-
return hostIgnores(path$
|
|
196
|
+
return (path$2) => {
|
|
197
|
+
if (path$2 === epoch()) return true;
|
|
198
|
+
if (this.registered.files.has(path$2) || this.registered.directories(path$2)) return false;
|
|
199
|
+
return hostIgnores(path$2) && !this.alsoWatched.some((watches) => watches(path$2));
|
|
191
200
|
};
|
|
192
201
|
}
|
|
193
202
|
/** Webpack's export conditions select the system's kit files as they
|
|
@@ -266,9 +275,9 @@ var AnimusWebpackPlugin = class {
|
|
|
266
275
|
files: /* @__PURE__ */ new Set([...plan.files, ...plan.missing]),
|
|
267
276
|
directories: withinDirectories(plan.directories)
|
|
268
277
|
};
|
|
269
|
-
for (const path$
|
|
270
|
-
else compilation.missingDependencies.add(path$
|
|
271
|
-
for (const path$
|
|
278
|
+
for (const path$3 of plan.files) if ((0, fs.existsSync)(path$3)) compilation.fileDependencies.add(path$3);
|
|
279
|
+
else compilation.missingDependencies.add(path$3);
|
|
280
|
+
for (const path$4 of plan.missing) compilation.missingDependencies.add(path$4);
|
|
272
281
|
for (const root of plan.directories) compilation.contextDependencies.add(root);
|
|
273
282
|
};
|
|
274
283
|
registerSystemDependencies();
|
|
@@ -295,13 +304,13 @@ var AnimusWebpackPlugin = class {
|
|
|
295
304
|
this.extractAliases(_compiler);
|
|
296
305
|
this.extractConditions(_compiler);
|
|
297
306
|
if (await this.rejoin()) {
|
|
298
|
-
this.session.agreeWithSystemAuthority();
|
|
307
|
+
await this.session.agreeWithSystemAuthority();
|
|
299
308
|
return;
|
|
300
309
|
}
|
|
301
310
|
const existing = (0, _animus_ui_extract_session.getAnalysisStartedPromise)(this.session.key);
|
|
302
311
|
if (existing) {
|
|
303
312
|
await existing;
|
|
304
|
-
this.session.agreeWithSystemAuthority();
|
|
313
|
+
await this.session.agreeWithSystemAuthority();
|
|
305
314
|
return;
|
|
306
315
|
}
|
|
307
316
|
const promise = this.session.runFullPipeline();
|
|
@@ -333,7 +342,7 @@ var AnimusWebpackPlugin = class {
|
|
|
333
342
|
}
|
|
334
343
|
async analyzeWatchTurn(compiler) {
|
|
335
344
|
if (!this.initialized && await this.rejoin()) {
|
|
336
|
-
this.session.agreeWithSystemAuthority();
|
|
345
|
+
await this.session.agreeWithSystemAuthority();
|
|
337
346
|
this.initialized = true;
|
|
338
347
|
this.lastBuiltEpoch = (0, _animus_ui_extract_session.getReplacementEpoch)(this.session.key);
|
|
339
348
|
this.epochMovedForNextCompilation = true;
|
|
@@ -351,7 +360,7 @@ var AnimusWebpackPlugin = class {
|
|
|
351
360
|
if ((0, _animus_ui_extract_session.getAnalysisStartedPromise)(this.session.key) === startup) (0, _animus_ui_extract_session.resetAnalysisStartedPromise)(this.session.key);
|
|
352
361
|
throw err;
|
|
353
362
|
}
|
|
354
|
-
this.session.agreeWithSystemAuthority();
|
|
363
|
+
await this.session.agreeWithSystemAuthority();
|
|
355
364
|
this.initialized = true;
|
|
356
365
|
this.lastBuiltEpoch = (0, _animus_ui_extract_session.getReplacementEpoch)(this.session.key);
|
|
357
366
|
this.epochMovedForNextCompilation = this.watchFailure !== null;
|
|
@@ -361,7 +370,7 @@ var AnimusWebpackPlugin = class {
|
|
|
361
370
|
modifiedFiles: compiler.modifiedFiles,
|
|
362
371
|
removedFiles: compiler.removedFiles
|
|
363
372
|
});
|
|
364
|
-
this.session.agreeWithSystemAuthority();
|
|
373
|
+
await this.session.agreeWithSystemAuthority();
|
|
365
374
|
const epoch = (0, _animus_ui_extract_session.getReplacementEpoch)(this.session.key);
|
|
366
375
|
this.epochMovedForNextCompilation = this.lastBuiltEpoch !== null && epoch !== null && epoch !== this.lastBuiltEpoch;
|
|
367
376
|
if (epoch !== null) this.lastBuiltEpoch = epoch;
|
|
@@ -417,6 +426,29 @@ var AnimusWebpackPlugin = class {
|
|
|
417
426
|
}
|
|
418
427
|
};
|
|
419
428
|
//#endregion
|
|
429
|
+
//#region src/quarantine.ts
|
|
430
|
+
/**
|
|
431
|
+
* layergate's webpack plugin for the `quarantine` option, loaded on first
|
|
432
|
+
* use: layergate is an optional peer. Only the client compiler builds
|
|
433
|
+
* stylesheets, so only it gets one.
|
|
434
|
+
*/
|
|
435
|
+
/** The error Turbopack meets: it runs no loader on a stylesheet's
|
|
436
|
+
* imports, so layergate cannot load a graph there. */
|
|
437
|
+
const QUARANTINE_TURBOPACK_MESSAGE = "[animus-extract] the `quarantine` option needs webpack: Turbopack runs no loader on the stylesheets a stylesheet imports, so it cannot keep them in `anm-vendor`. Run `next build --webpack` and `next dev --webpack`, or remove `quarantine` [layergate.turbopack]";
|
|
438
|
+
function quarantinePlugin(options, order, declaredBy) {
|
|
439
|
+
let layergate;
|
|
440
|
+
try {
|
|
441
|
+
layergate = (0, module$1.createRequire)(require("url").pathToFileURL(__filename).href)("@animus-ui/layergate/webpack");
|
|
442
|
+
} catch (cause) {
|
|
443
|
+
throw (0, _animus_ui_extract_pipeline.layergateMissing)("@animus-ui/next-plugin", cause);
|
|
444
|
+
}
|
|
445
|
+
return new layergate.LayergatePlugin({
|
|
446
|
+
...(0, _animus_ui_extract_pipeline.layergateOptions)(options, order),
|
|
447
|
+
declaredBy,
|
|
448
|
+
watchIgnored: false
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
420
452
|
//#region src/with-animus.ts
|
|
421
453
|
const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
422
454
|
const __dirname$1 = (0, path.dirname)(__filename$1);
|
|
@@ -434,7 +466,8 @@ function withAnimus(options) {
|
|
|
434
466
|
"turbopack",
|
|
435
467
|
"unstable_turbopack",
|
|
436
468
|
"loaderPath",
|
|
437
|
-
"phase"
|
|
469
|
+
"phase",
|
|
470
|
+
"quarantine"
|
|
438
471
|
], [], {
|
|
439
472
|
onUnknownKey: "warn",
|
|
440
473
|
warn: (message) => console.warn(`[animus-extract] ${message}`)
|
|
@@ -446,8 +479,10 @@ function withAnimus(options) {
|
|
|
446
479
|
const build = (0, _animus_ui_extract_session.createBuildId)();
|
|
447
480
|
const appRoot = options.root === void 0 ? process.cwd() : (0, path.resolve)(options.root);
|
|
448
481
|
return (authoredConfig) => {
|
|
449
|
-
const nextConfig =
|
|
450
|
-
|
|
482
|
+
const nextConfig = withTranspiled(authoredConfig, transpiledPackages(appRoot));
|
|
483
|
+
const turbopack = require_turbopack_config.resolveTurbopackMode(options);
|
|
484
|
+
if (options.quarantine && (turbopack || "TURBOPACK" in process.env)) throw new _animus_ui_extract_pipeline.AnimusConfigError(QUARANTINE_TURBOPACK_MESSAGE);
|
|
485
|
+
if (turbopack) {
|
|
451
486
|
warnTurbopackCwdRoot(options, appRoot);
|
|
452
487
|
return turbopackConfig(nextConfig, options, build, appRoot);
|
|
453
488
|
}
|
|
@@ -459,8 +494,11 @@ function withAnimus(options) {
|
|
|
459
494
|
if (context.dir?.length && !sameDirectory(context.dir, appRoot)) throw new _animus_ui_extract_pipeline.AnimusConfigError(`[animus-extract] Next builds ${context.dir}, but Animus read the app's source kits from ${appRoot}. Run next from the app directory, or pass withAnimus({ root }) naming it.`);
|
|
460
495
|
const rootDir = appRoot;
|
|
461
496
|
const { mode } = (0, _animus_ui_extract_pipeline.resolveMode)(options.mode, () => context.dev === true ? "development" : "production");
|
|
497
|
+
const vendorOrder = options.quarantine ? (0, _animus_ui_extract_pipeline.withVendorLayer)(options.layers) : void 0;
|
|
498
|
+
const layers = vendorOrder ?? options.layers;
|
|
462
499
|
const plugin = new AnimusWebpackPlugin({
|
|
463
500
|
...options,
|
|
501
|
+
layers,
|
|
464
502
|
mode
|
|
465
503
|
}, {
|
|
466
504
|
development: context.dev === true,
|
|
@@ -473,13 +511,15 @@ function withAnimus(options) {
|
|
|
473
511
|
const stubCssPath = (0, _animus_ui_extract_session.stylesPath)(sessionDir);
|
|
474
512
|
if (!(0, fs.existsSync)(stubCssPath)) {
|
|
475
513
|
const { declaration } = (0, _animus_ui_extract_pipeline.assembleStylesheet)({
|
|
476
|
-
layers
|
|
514
|
+
layers,
|
|
477
515
|
variableCss: "",
|
|
478
516
|
globalCss: "",
|
|
479
517
|
split: true
|
|
480
518
|
});
|
|
481
519
|
(0, fs.writeFileSync)(stubCssPath, declaration);
|
|
482
520
|
}
|
|
521
|
+
const sessionFontPreloadsPath = (0, _animus_ui_extract_session.fontPreloadsPath)(sessionDir);
|
|
522
|
+
if (!(0, fs.existsSync)(sessionFontPreloadsPath)) (0, fs.writeFileSync)(sessionFontPreloadsPath, (0, _animus_ui_extract_pipeline.fontPreloadsModule)([]));
|
|
483
523
|
if (!warnedGitignore) {
|
|
484
524
|
warnedGitignore = true;
|
|
485
525
|
try {
|
|
@@ -493,6 +533,11 @@ function withAnimus(options) {
|
|
|
493
533
|
config.plugins = config.plugins || [];
|
|
494
534
|
config.plugins.push(plugin);
|
|
495
535
|
plugin.watchConfig(config);
|
|
536
|
+
if (options.quarantine && vendorOrder && context.isServer !== true) {
|
|
537
|
+
const gate = quarantinePlugin(options.quarantine, vendorOrder, stubCssPath);
|
|
538
|
+
config.plugins.push(gate);
|
|
539
|
+
plugin.watchAlso((path$1) => gate.watches(path$1));
|
|
540
|
+
}
|
|
496
541
|
const DefinePlugin = context.webpack?.DefinePlugin;
|
|
497
542
|
if (DefinePlugin) config.plugins.push(new DefinePlugin({ __ANIMUS_DEV__: JSON.stringify(mode === "development") }));
|
|
498
543
|
config.resolve = config.resolve || {};
|
|
@@ -504,6 +549,7 @@ function withAnimus(options) {
|
|
|
504
549
|
compiler.hooks.normalModuleFactory.tap("AnimusVirtualResolve", (nmf) => {
|
|
505
550
|
nmf.hooks.beforeResolve.tap("AnimusVirtualResolve", (resolveData) => {
|
|
506
551
|
if (resolveData.request === "virtual:animus/system-props") resolveData.request = sessionSystemPropsPath;
|
|
552
|
+
if (resolveData.request === _animus_ui_extract_session.FONT_PRELOADS_MODULE_ID) resolveData.request = sessionFontPreloadsPath;
|
|
507
553
|
if (resolveData.request === "virtual:animus/styles.css" || resolveData.request === _animus_ui_extract_session.ANIMUS_CSS_MODULE_ID) resolveData.request = (0, _animus_ui_extract_session.stylesPath)(sessionDir);
|
|
508
554
|
const srcEntry = plugin.getExternalSourceEntries().get(resolveData.request);
|
|
509
555
|
if (srcEntry) {
|
|
@@ -560,11 +606,7 @@ function bindTurbopackWatchDeathReport(outcome, rootDir) {
|
|
|
560
606
|
console.error(`[animus-extract] dev watcher for ${rootDir} died — source edits are no longer extracted; restart the dev server`);
|
|
561
607
|
};
|
|
562
608
|
}
|
|
563
|
-
|
|
564
|
-
* `transpilePackages`. The kit redirect points both bundles at a kit's
|
|
565
|
-
* source, but Next's server keeps an installed package external, and so
|
|
566
|
-
* loads its runtime entry, unless the package is transpiled; transpiling
|
|
567
|
-
* also compiles its TypeScript source. */
|
|
609
|
+
const NEXT_PLUGIN_PACKAGE = "@animus-ui/next-plugin";
|
|
568
610
|
let warnedTurbopackCwd = false;
|
|
569
611
|
/** Turbopack's loaders get no app dir either, so a cwd that is not the app
|
|
570
612
|
* cannot be detected later: warn at startup when the cwd holds no Next
|
|
@@ -581,15 +623,25 @@ function warnTurbopackCwdRoot(options, appRoot) {
|
|
|
581
623
|
warnedTurbopackCwd = true;
|
|
582
624
|
console.warn(`[animus-extract] the current directory (${appRoot}) holds no next.config: under Turbopack, Animus reads the app from the current directory. Run next from the app directory, or pass withAnimus({ root }) naming it.`);
|
|
583
625
|
}
|
|
584
|
-
|
|
626
|
+
/** The config with `packages` added to `transpilePackages`. Next's server
|
|
627
|
+
* keeps an installed package external, and so loads its runtime entry,
|
|
628
|
+
* unless the package is transpiled. */
|
|
629
|
+
function withTranspiled(nextConfig, packages) {
|
|
585
630
|
const declared = nextConfig.transpilePackages ?? [];
|
|
586
|
-
const
|
|
587
|
-
if (
|
|
631
|
+
const added = packages.filter((name) => !declared.includes(name));
|
|
632
|
+
if (added.length === 0) return nextConfig;
|
|
588
633
|
return {
|
|
589
634
|
...nextConfig,
|
|
590
|
-
transpilePackages: [...declared, ...
|
|
635
|
+
transpilePackages: [...declared, ...added]
|
|
591
636
|
};
|
|
592
637
|
}
|
|
638
|
+
/** The packages Next must transpile: the source kits the app depends on,
|
|
639
|
+
* since the kit redirect points both bundles at a kit's TypeScript source,
|
|
640
|
+
* and this package, whose font-preloads entry imports the session module
|
|
641
|
+
* only the bundle's alias resolves. */
|
|
642
|
+
function transpiledPackages(rootDir) {
|
|
643
|
+
return [...(0, _animus_ui_extract_pipeline.sourceKitDependencies)(rootDir, (0, _animus_ui_extract_session.requireEngine)()).map((kit) => kit.name), NEXT_PLUGIN_PACKAGE];
|
|
644
|
+
}
|
|
593
645
|
function turbopackConfig(nextConfig, options, build, appRoot) {
|
|
594
646
|
const resolveExtensions = nextConfig.turbopack?.resolveExtensions ?? nextConfig.experimental?.turbo?.resolveExtensions;
|
|
595
647
|
const outputExclude = nextConfig.distDir ? (0, _animus_ui_extract_pipeline.outputExclusion)(appRoot, (0, path.resolve)(appRoot, nextConfig.distDir)) : null;
|
|
@@ -647,6 +699,7 @@ async function analyzeForTurbopack(options, phase, rootDir, resolveExtensions, o
|
|
|
647
699
|
unbundledComputedImports: true,
|
|
648
700
|
build: `${build}-${phase}`
|
|
649
701
|
});
|
|
702
|
+
session.writesFontPreloadsModule = true;
|
|
650
703
|
const owner = turbopackOwner(build);
|
|
651
704
|
owner.session?.close();
|
|
652
705
|
owner.watcher?.close();
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { a as resolveTurbopackMode, i as resolveTurbopackLoaderPath, n as buildTurbopackConfig, o as turbopackSideEffectsLimits, r as isTurbopackDevelopment, s as resolveAnimusLoaderPath, t as ANIMUS_TURBOPACK_RULE_GLOB } from "./turbopack-config-
|
|
2
|
-
import { AnimusConfigError, assembleStylesheet, assertKnownOptionKeys, assertSupportedEngine, buildPathAliasesJson, builtInAssetClassification, isEngineTransformExtension, isExcludedPackageRelativePath, isPathWithinRoot, keepsKitSourceEffects, nextImageAssetClassification, outputExclusion, resolveMode, sourceKitDependencies, turbopackExtensionPolicy, webpackExtensionPolicy } from "@animus-ui/extract/pipeline";
|
|
3
|
-
import { ANIMUS_CSS_MODULE_ID, ANIMUS_CSS_MODULE_ID as ANIMUS_CSS_MODULE_ID$1, ExtractionSession, TURBOPACK_SYSTEM_PROPS_ID, createBuildId, getAnalysisStartedPromise, getReplacementEpoch, getSharedCss, getSharedExternalDirs, getSharedExternalEntries, getSharedExternalSideEffects, replacementEpochPath, requireEngine, resetAnalysisStartedPromise, runSessionPipeline, sessionArtifactDir, setAnalysisStartedPromise, startTurbopackWatcher, stylesPath, systemPropsPath } from "@animus-ui/extract/session";
|
|
1
|
+
import { a as resolveTurbopackMode, i as resolveTurbopackLoaderPath, n as buildTurbopackConfig, o as turbopackSideEffectsLimits, r as isTurbopackDevelopment, s as resolveAnimusLoaderPath, t as ANIMUS_TURBOPACK_RULE_GLOB } from "./turbopack-config-BOUPGkmi.mjs";
|
|
2
|
+
import { AnimusConfigError, assembleStylesheet, assertKnownOptionKeys, assertSupportedEngine, buildPathAliasesJson, builtInAssetClassification, fontPreloadsModule, isEngineTransformExtension, isExcludedPackageRelativePath, isPathWithinRoot, keepsKitSourceEffects, layergateMissing, layergateOptions, nextImageAssetClassification, outputExclusion, resolveMode, sourceKitDependencies, turbopackExtensionPolicy, webpackExtensionPolicy, withVendorLayer } from "@animus-ui/extract/pipeline";
|
|
3
|
+
import { ANIMUS_CSS_MODULE_ID, ANIMUS_CSS_MODULE_ID as ANIMUS_CSS_MODULE_ID$1, ExtractionSession, FONT_PRELOADS_MODULE_ID, TURBOPACK_SYSTEM_PROPS_ID, createBuildId, fontPreloadsPath, getAnalysisStartedPromise, getReplacementEpoch, getSharedCss, getSharedExternalDirs, getSharedExternalEntries, getSharedExternalSideEffects, replacementEpochPath, requireEngine, resetAnalysisStartedPromise, runSessionPipeline, sessionArtifactDir, setAnalysisStartedPromise, startTurbopackWatcher, stylesPath, systemPropsPath } from "@animus-ui/extract/session";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "fs";
|
|
5
5
|
import { dirname, join, resolve, sep } from "path";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
|
+
import { createRequire } from "module";
|
|
7
8
|
//#region src/same-directory.ts
|
|
8
9
|
/** Whether two paths name one directory: by real path, which resolves a
|
|
9
10
|
* trailing slash, a symlink and the filesystem's own spelling, else by
|
|
@@ -139,6 +140,8 @@ var AnimusWebpackPlugin = class {
|
|
|
139
140
|
files: /* @__PURE__ */ new Set(),
|
|
140
141
|
directories: () => false
|
|
141
142
|
};
|
|
143
|
+
/** Other files the watcher must see, by the plugins that read them. */
|
|
144
|
+
alsoWatched = [];
|
|
142
145
|
/** The webpack config Next hands its watcher, when withAnimus made it. */
|
|
143
146
|
watchedConfig;
|
|
144
147
|
/** `development` is `next dev`: an error-level diagnostic reports and the
|
|
@@ -148,6 +151,7 @@ var AnimusWebpackPlugin = class {
|
|
|
148
151
|
assertSupportedEngine(options.engine);
|
|
149
152
|
this.session = new ExtractionSession(options, { build });
|
|
150
153
|
this.session.development = development;
|
|
154
|
+
this.session.writesFontPreloadsModule = true;
|
|
151
155
|
this.session.delivery = {
|
|
152
156
|
...this.session.delivery,
|
|
153
157
|
systemPropsModuleId: TURBOPACK_SYSTEM_PROPS_ID
|
|
@@ -165,6 +169,11 @@ var AnimusWebpackPlugin = class {
|
|
|
165
169
|
watchConfig(config) {
|
|
166
170
|
this.watchedConfig = config;
|
|
167
171
|
}
|
|
172
|
+
/** Makes `watchIgnored` watch the paths `watches` names too: one matcher
|
|
173
|
+
* owns the host's watch options. */
|
|
174
|
+
watchAlso(watches) {
|
|
175
|
+
this.alsoWatched.push(watches);
|
|
176
|
+
}
|
|
168
177
|
/**
|
|
169
178
|
* `watchOptions.ignored` for the host's own `ignored`: this session's epoch
|
|
170
179
|
* file stays ignored, and every file and directory the Session's watch plan
|
|
@@ -186,7 +195,7 @@ var AnimusWebpackPlugin = class {
|
|
|
186
195
|
return (path) => {
|
|
187
196
|
if (path === epoch()) return true;
|
|
188
197
|
if (this.registered.files.has(path) || this.registered.directories(path)) return false;
|
|
189
|
-
return hostIgnores(path);
|
|
198
|
+
return hostIgnores(path) && !this.alsoWatched.some((watches) => watches(path));
|
|
190
199
|
};
|
|
191
200
|
}
|
|
192
201
|
/** Webpack's export conditions select the system's kit files as they
|
|
@@ -294,13 +303,13 @@ var AnimusWebpackPlugin = class {
|
|
|
294
303
|
this.extractAliases(_compiler);
|
|
295
304
|
this.extractConditions(_compiler);
|
|
296
305
|
if (await this.rejoin()) {
|
|
297
|
-
this.session.agreeWithSystemAuthority();
|
|
306
|
+
await this.session.agreeWithSystemAuthority();
|
|
298
307
|
return;
|
|
299
308
|
}
|
|
300
309
|
const existing = getAnalysisStartedPromise(this.session.key);
|
|
301
310
|
if (existing) {
|
|
302
311
|
await existing;
|
|
303
|
-
this.session.agreeWithSystemAuthority();
|
|
312
|
+
await this.session.agreeWithSystemAuthority();
|
|
304
313
|
return;
|
|
305
314
|
}
|
|
306
315
|
const promise = this.session.runFullPipeline();
|
|
@@ -332,7 +341,7 @@ var AnimusWebpackPlugin = class {
|
|
|
332
341
|
}
|
|
333
342
|
async analyzeWatchTurn(compiler) {
|
|
334
343
|
if (!this.initialized && await this.rejoin()) {
|
|
335
|
-
this.session.agreeWithSystemAuthority();
|
|
344
|
+
await this.session.agreeWithSystemAuthority();
|
|
336
345
|
this.initialized = true;
|
|
337
346
|
this.lastBuiltEpoch = getReplacementEpoch(this.session.key);
|
|
338
347
|
this.epochMovedForNextCompilation = true;
|
|
@@ -350,7 +359,7 @@ var AnimusWebpackPlugin = class {
|
|
|
350
359
|
if (getAnalysisStartedPromise(this.session.key) === startup) resetAnalysisStartedPromise(this.session.key);
|
|
351
360
|
throw err;
|
|
352
361
|
}
|
|
353
|
-
this.session.agreeWithSystemAuthority();
|
|
362
|
+
await this.session.agreeWithSystemAuthority();
|
|
354
363
|
this.initialized = true;
|
|
355
364
|
this.lastBuiltEpoch = getReplacementEpoch(this.session.key);
|
|
356
365
|
this.epochMovedForNextCompilation = this.watchFailure !== null;
|
|
@@ -360,7 +369,7 @@ var AnimusWebpackPlugin = class {
|
|
|
360
369
|
modifiedFiles: compiler.modifiedFiles,
|
|
361
370
|
removedFiles: compiler.removedFiles
|
|
362
371
|
});
|
|
363
|
-
this.session.agreeWithSystemAuthority();
|
|
372
|
+
await this.session.agreeWithSystemAuthority();
|
|
364
373
|
const epoch = getReplacementEpoch(this.session.key);
|
|
365
374
|
this.epochMovedForNextCompilation = this.lastBuiltEpoch !== null && epoch !== null && epoch !== this.lastBuiltEpoch;
|
|
366
375
|
if (epoch !== null) this.lastBuiltEpoch = epoch;
|
|
@@ -416,6 +425,29 @@ var AnimusWebpackPlugin = class {
|
|
|
416
425
|
}
|
|
417
426
|
};
|
|
418
427
|
//#endregion
|
|
428
|
+
//#region src/quarantine.ts
|
|
429
|
+
/**
|
|
430
|
+
* layergate's webpack plugin for the `quarantine` option, loaded on first
|
|
431
|
+
* use: layergate is an optional peer. Only the client compiler builds
|
|
432
|
+
* stylesheets, so only it gets one.
|
|
433
|
+
*/
|
|
434
|
+
/** The error Turbopack meets: it runs no loader on a stylesheet's
|
|
435
|
+
* imports, so layergate cannot load a graph there. */
|
|
436
|
+
const QUARANTINE_TURBOPACK_MESSAGE = "[animus-extract] the `quarantine` option needs webpack: Turbopack runs no loader on the stylesheets a stylesheet imports, so it cannot keep them in `anm-vendor`. Run `next build --webpack` and `next dev --webpack`, or remove `quarantine` [layergate.turbopack]";
|
|
437
|
+
function quarantinePlugin(options, order, declaredBy) {
|
|
438
|
+
let layergate;
|
|
439
|
+
try {
|
|
440
|
+
layergate = createRequire(import.meta.url)("@animus-ui/layergate/webpack");
|
|
441
|
+
} catch (cause) {
|
|
442
|
+
throw layergateMissing("@animus-ui/next-plugin", cause);
|
|
443
|
+
}
|
|
444
|
+
return new layergate.LayergatePlugin({
|
|
445
|
+
...layergateOptions(options, order),
|
|
446
|
+
declaredBy,
|
|
447
|
+
watchIgnored: false
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
419
451
|
//#region src/with-animus.ts
|
|
420
452
|
const __filename = fileURLToPath(import.meta.url);
|
|
421
453
|
const __dirname = dirname(__filename);
|
|
@@ -433,7 +465,8 @@ function withAnimus(options) {
|
|
|
433
465
|
"turbopack",
|
|
434
466
|
"unstable_turbopack",
|
|
435
467
|
"loaderPath",
|
|
436
|
-
"phase"
|
|
468
|
+
"phase",
|
|
469
|
+
"quarantine"
|
|
437
470
|
], [], {
|
|
438
471
|
onUnknownKey: "warn",
|
|
439
472
|
warn: (message) => console.warn(`[animus-extract] ${message}`)
|
|
@@ -445,8 +478,10 @@ function withAnimus(options) {
|
|
|
445
478
|
const build = createBuildId();
|
|
446
479
|
const appRoot = options.root === void 0 ? process.cwd() : resolve(options.root);
|
|
447
480
|
return (authoredConfig) => {
|
|
448
|
-
const nextConfig =
|
|
449
|
-
|
|
481
|
+
const nextConfig = withTranspiled(authoredConfig, transpiledPackages(appRoot));
|
|
482
|
+
const turbopack = resolveTurbopackMode(options);
|
|
483
|
+
if (options.quarantine && (turbopack || "TURBOPACK" in process.env)) throw new AnimusConfigError(QUARANTINE_TURBOPACK_MESSAGE);
|
|
484
|
+
if (turbopack) {
|
|
450
485
|
warnTurbopackCwdRoot(options, appRoot);
|
|
451
486
|
return turbopackConfig(nextConfig, options, build, appRoot);
|
|
452
487
|
}
|
|
@@ -458,8 +493,11 @@ function withAnimus(options) {
|
|
|
458
493
|
if (context.dir?.length && !sameDirectory(context.dir, appRoot)) throw new AnimusConfigError(`[animus-extract] Next builds ${context.dir}, but Animus read the app's source kits from ${appRoot}. Run next from the app directory, or pass withAnimus({ root }) naming it.`);
|
|
459
494
|
const rootDir = appRoot;
|
|
460
495
|
const { mode } = resolveMode(options.mode, () => context.dev === true ? "development" : "production");
|
|
496
|
+
const vendorOrder = options.quarantine ? withVendorLayer(options.layers) : void 0;
|
|
497
|
+
const layers = vendorOrder ?? options.layers;
|
|
461
498
|
const plugin = new AnimusWebpackPlugin({
|
|
462
499
|
...options,
|
|
500
|
+
layers,
|
|
463
501
|
mode
|
|
464
502
|
}, {
|
|
465
503
|
development: context.dev === true,
|
|
@@ -472,13 +510,15 @@ function withAnimus(options) {
|
|
|
472
510
|
const stubCssPath = stylesPath(sessionDir);
|
|
473
511
|
if (!existsSync(stubCssPath)) {
|
|
474
512
|
const { declaration } = assembleStylesheet({
|
|
475
|
-
layers
|
|
513
|
+
layers,
|
|
476
514
|
variableCss: "",
|
|
477
515
|
globalCss: "",
|
|
478
516
|
split: true
|
|
479
517
|
});
|
|
480
518
|
writeFileSync(stubCssPath, declaration);
|
|
481
519
|
}
|
|
520
|
+
const sessionFontPreloadsPath = fontPreloadsPath(sessionDir);
|
|
521
|
+
if (!existsSync(sessionFontPreloadsPath)) writeFileSync(sessionFontPreloadsPath, fontPreloadsModule([]));
|
|
482
522
|
if (!warnedGitignore) {
|
|
483
523
|
warnedGitignore = true;
|
|
484
524
|
try {
|
|
@@ -492,6 +532,11 @@ function withAnimus(options) {
|
|
|
492
532
|
config.plugins = config.plugins || [];
|
|
493
533
|
config.plugins.push(plugin);
|
|
494
534
|
plugin.watchConfig(config);
|
|
535
|
+
if (options.quarantine && vendorOrder && context.isServer !== true) {
|
|
536
|
+
const gate = quarantinePlugin(options.quarantine, vendorOrder, stubCssPath);
|
|
537
|
+
config.plugins.push(gate);
|
|
538
|
+
plugin.watchAlso((path) => gate.watches(path));
|
|
539
|
+
}
|
|
495
540
|
const DefinePlugin = context.webpack?.DefinePlugin;
|
|
496
541
|
if (DefinePlugin) config.plugins.push(new DefinePlugin({ __ANIMUS_DEV__: JSON.stringify(mode === "development") }));
|
|
497
542
|
config.resolve = config.resolve || {};
|
|
@@ -503,6 +548,7 @@ function withAnimus(options) {
|
|
|
503
548
|
compiler.hooks.normalModuleFactory.tap("AnimusVirtualResolve", (nmf) => {
|
|
504
549
|
nmf.hooks.beforeResolve.tap("AnimusVirtualResolve", (resolveData) => {
|
|
505
550
|
if (resolveData.request === "virtual:animus/system-props") resolveData.request = sessionSystemPropsPath;
|
|
551
|
+
if (resolveData.request === FONT_PRELOADS_MODULE_ID) resolveData.request = sessionFontPreloadsPath;
|
|
506
552
|
if (resolveData.request === "virtual:animus/styles.css" || resolveData.request === ANIMUS_CSS_MODULE_ID$1) resolveData.request = stylesPath(sessionDir);
|
|
507
553
|
const srcEntry = plugin.getExternalSourceEntries().get(resolveData.request);
|
|
508
554
|
if (srcEntry) {
|
|
@@ -559,11 +605,7 @@ function bindTurbopackWatchDeathReport(outcome, rootDir) {
|
|
|
559
605
|
console.error(`[animus-extract] dev watcher for ${rootDir} died — source edits are no longer extracted; restart the dev server`);
|
|
560
606
|
};
|
|
561
607
|
}
|
|
562
|
-
|
|
563
|
-
* `transpilePackages`. The kit redirect points both bundles at a kit's
|
|
564
|
-
* source, but Next's server keeps an installed package external, and so
|
|
565
|
-
* loads its runtime entry, unless the package is transpiled; transpiling
|
|
566
|
-
* also compiles its TypeScript source. */
|
|
608
|
+
const NEXT_PLUGIN_PACKAGE = "@animus-ui/next-plugin";
|
|
567
609
|
let warnedTurbopackCwd = false;
|
|
568
610
|
/** Turbopack's loaders get no app dir either, so a cwd that is not the app
|
|
569
611
|
* cannot be detected later: warn at startup when the cwd holds no Next
|
|
@@ -580,15 +622,25 @@ function warnTurbopackCwdRoot(options, appRoot) {
|
|
|
580
622
|
warnedTurbopackCwd = true;
|
|
581
623
|
console.warn(`[animus-extract] the current directory (${appRoot}) holds no next.config: under Turbopack, Animus reads the app from the current directory. Run next from the app directory, or pass withAnimus({ root }) naming it.`);
|
|
582
624
|
}
|
|
583
|
-
|
|
625
|
+
/** The config with `packages` added to `transpilePackages`. Next's server
|
|
626
|
+
* keeps an installed package external, and so loads its runtime entry,
|
|
627
|
+
* unless the package is transpiled. */
|
|
628
|
+
function withTranspiled(nextConfig, packages) {
|
|
584
629
|
const declared = nextConfig.transpilePackages ?? [];
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
630
|
+
const added = packages.filter((name) => !declared.includes(name));
|
|
631
|
+
if (added.length === 0) return nextConfig;
|
|
587
632
|
return {
|
|
588
633
|
...nextConfig,
|
|
589
|
-
transpilePackages: [...declared, ...
|
|
634
|
+
transpilePackages: [...declared, ...added]
|
|
590
635
|
};
|
|
591
636
|
}
|
|
637
|
+
/** The packages Next must transpile: the source kits the app depends on,
|
|
638
|
+
* since the kit redirect points both bundles at a kit's TypeScript source,
|
|
639
|
+
* and this package, whose font-preloads entry imports the session module
|
|
640
|
+
* only the bundle's alias resolves. */
|
|
641
|
+
function transpiledPackages(rootDir) {
|
|
642
|
+
return [...sourceKitDependencies(rootDir, requireEngine()).map((kit) => kit.name), NEXT_PLUGIN_PACKAGE];
|
|
643
|
+
}
|
|
592
644
|
function turbopackConfig(nextConfig, options, build, appRoot) {
|
|
593
645
|
const resolveExtensions = nextConfig.turbopack?.resolveExtensions ?? nextConfig.experimental?.turbo?.resolveExtensions;
|
|
594
646
|
const outputExclude = nextConfig.distDir ? outputExclusion(appRoot, resolve(appRoot, nextConfig.distDir)) : null;
|
|
@@ -646,6 +698,7 @@ async function analyzeForTurbopack(options, phase, rootDir, resolveExtensions, o
|
|
|
646
698
|
unbundledComputedImports: true,
|
|
647
699
|
build: `${build}-${phase}`
|
|
648
700
|
});
|
|
701
|
+
session.writesFontPreloadsModule = true;
|
|
649
702
|
const owner = turbopackOwner(build);
|
|
650
703
|
owner.session?.close();
|
|
651
704
|
owner.watcher?.close();
|
package/dist/plugin.d.ts
CHANGED
|
@@ -127,6 +127,8 @@ export declare class AnimusWebpackPlugin {
|
|
|
127
127
|
/** What the Session's watch plan last registered: `watchIgnored` never
|
|
128
128
|
* ignores it. */
|
|
129
129
|
private registered;
|
|
130
|
+
/** Other files the watcher must see, by the plugins that read them. */
|
|
131
|
+
private readonly alsoWatched;
|
|
130
132
|
/** The webpack config Next hands its watcher, when withAnimus made it. */
|
|
131
133
|
private watchedConfig;
|
|
132
134
|
/** `development` is `next dev`: an error-level diagnostic reports and the
|
|
@@ -141,6 +143,9 @@ export declare class AnimusWebpackPlugin {
|
|
|
141
143
|
watchConfig(config: {
|
|
142
144
|
watchOptions?: WatchOptions;
|
|
143
145
|
}): void;
|
|
146
|
+
/** Makes `watchIgnored` watch the paths `watches` names too: one matcher
|
|
147
|
+
* owns the host's watch options. */
|
|
148
|
+
watchAlso(watches: (path: string) => boolean): void;
|
|
144
149
|
/**
|
|
145
150
|
* `watchOptions.ignored` for the host's own `ignored`: this session's epoch
|
|
146
151
|
* file stays ignored, and every file and directory the Session's watch plan
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"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|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnimusQuarantineOptions } from '@animus-ui/extract/pipeline';
|
|
2
|
+
import type { LayergatePlugin } from '@animus-ui/layergate/webpack';
|
|
3
|
+
/** The error Turbopack meets: it runs no loader on a stylesheet's
|
|
4
|
+
* imports, so layergate cannot load a graph there. */
|
|
5
|
+
export declare const QUARANTINE_TURBOPACK_MESSAGE: string;
|
|
6
|
+
export declare function quarantinePlugin(options: AnimusQuarantineOptions, order: readonly string[], declaredBy: string): LayergatePlugin;
|
|
7
|
+
//# sourceMappingURL=quarantine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quarantine.d.ts","sourceRoot":"","sources":["../src/quarantine.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE;uDACuD;AACvD,eAAO,MAAM,4BAA4B,QAIO,CAAC;AAEjD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,UAAU,EAAE,MAAM,GACjB,eAAe,CAcjB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "__toESM", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return __toESM;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ENGINE_TRANSFORM_EXTENSIONS, fileSideEffects, findPackageRoot, kitSourceModuleSideEffects } from "@animus-ui/extract/pipeline";
|
|
2
|
-
import { ANIMUS_CSS_MODULE_ID, STYLES_ARTIFACT, SYSTEM_PROPS_ARTIFACT, TURBOPACK_SYSTEM_PROPS_ID as TURBOPACK_SYSTEM_PROPS_ID$1 } from "@animus-ui/extract/session";
|
|
2
|
+
import { ANIMUS_CSS_MODULE_ID, FONT_PRELOADS_ARTIFACT, FONT_PRELOADS_MODULE_ID, STYLES_ARTIFACT, SYSTEM_PROPS_ARTIFACT, TURBOPACK_SYSTEM_PROPS_ID as TURBOPACK_SYSTEM_PROPS_ID$1 } from "@animus-ui/extract/session";
|
|
3
3
|
import { existsSync } from "fs";
|
|
4
4
|
import { dirname, join, relative, resolve } from "path";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
@@ -48,7 +48,8 @@ function buildTurbopackConfig(args) {
|
|
|
48
48
|
if (options.cssImportTarget !== void 0) loaderOptions.cssImportTarget = options.cssImportTarget;
|
|
49
49
|
const resolveAlias = {
|
|
50
50
|
[TURBOPACK_SYSTEM_PROPS_ID$1]: rootRelativeRequest(rootDir, join(sessionDir, SYSTEM_PROPS_ARTIFACT)),
|
|
51
|
-
[ANIMUS_CSS_MODULE_ID]: rootRelativeRequest(rootDir, join(sessionDir, STYLES_ARTIFACT))
|
|
51
|
+
[ANIMUS_CSS_MODULE_ID]: rootRelativeRequest(rootDir, join(sessionDir, STYLES_ARTIFACT)),
|
|
52
|
+
[FONT_PRELOADS_MODULE_ID]: rootRelativeRequest(rootDir, join(sessionDir, FONT_PRELOADS_ARTIFACT))
|
|
52
53
|
};
|
|
53
54
|
for (const [specifier, srcEntry] of externalSourceEntries) resolveAlias[specifier] = rootRelativeRequest(rootDir, srcEntry);
|
|
54
55
|
return {
|
|
@@ -47,7 +47,8 @@ function buildTurbopackConfig(args) {
|
|
|
47
47
|
if (options.cssImportTarget !== void 0) loaderOptions.cssImportTarget = options.cssImportTarget;
|
|
48
48
|
const resolveAlias = {
|
|
49
49
|
[_animus_ui_extract_session.TURBOPACK_SYSTEM_PROPS_ID]: rootRelativeRequest(rootDir, (0, path.join)(sessionDir, _animus_ui_extract_session.SYSTEM_PROPS_ARTIFACT)),
|
|
50
|
-
[_animus_ui_extract_session.ANIMUS_CSS_MODULE_ID]: rootRelativeRequest(rootDir, (0, path.join)(sessionDir, _animus_ui_extract_session.STYLES_ARTIFACT))
|
|
50
|
+
[_animus_ui_extract_session.ANIMUS_CSS_MODULE_ID]: rootRelativeRequest(rootDir, (0, path.join)(sessionDir, _animus_ui_extract_session.STYLES_ARTIFACT)),
|
|
51
|
+
[_animus_ui_extract_session.FONT_PRELOADS_MODULE_ID]: rootRelativeRequest(rootDir, (0, path.join)(sessionDir, _animus_ui_extract_session.FONT_PRELOADS_ARTIFACT))
|
|
51
52
|
};
|
|
52
53
|
for (const [specifier, srcEntry] of externalSourceEntries) resolveAlias[specifier] = rootRelativeRequest(rootDir, srcEntry);
|
|
53
54
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turbopack-config.d.ts","sourceRoot":"","sources":["../src/turbopack-config.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"turbopack-config.d.ts","sourceRoot":"","sources":["../src/turbopack-config.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;wEACwE;AAExE,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,sBAAsB,CAAA;KAAE,CAAC,CAAC;CACrE;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED;;;0DAG0D;AAC1D,eAAO,MAAM,0BAA0B,QAAiD,CAAC;AAEzF,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAMT;AAED;0CAC0C;AAC1C,wBAAgB,sBAAsB,CACpC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAET;AAMD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,qBAAqB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;CACtB,GAAG,uBAAuB,CA+C1B;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,qBAAqB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClD,yBAAyB,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GACtD,MAAM,EAAE,CA0BV;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMpE"}
|
|
@@ -2,34 +2,13 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
-
key = keys[i];
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: ((k) => from[k]).bind(null, key),
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
//#endregion
|
|
27
|
-
const require_turbopack_config = require("./turbopack-config-BoNfzhNu.cjs");
|
|
5
|
+
const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
|
|
6
|
+
const require_turbopack_config = require("./turbopack-config-W5eoa_xN.cjs");
|
|
28
7
|
const require_loader_core = require("./loader-core-Bz52QNm3.cjs");
|
|
29
8
|
let _animus_ui_extract_pipeline = require("@animus-ui/extract/pipeline");
|
|
30
9
|
let _animus_ui_extract_session = require("@animus-ui/extract/session");
|
|
31
10
|
let fs = require("fs");
|
|
32
|
-
fs = __toESM(fs);
|
|
11
|
+
fs = require_rolldown_runtime.__toESM(fs);
|
|
33
12
|
let path = require("path");
|
|
34
13
|
//#region src/turbopack-loader.ts
|
|
35
14
|
/** Each build's last hydration in this worker, so a worker serving two
|
|
@@ -106,7 +85,8 @@ function hydrateSession(key, sessionDir, sessionId) {
|
|
|
106
85
|
const manifestRaw = readFileOrNull((0, _animus_ui_extract_session.manifestPath)(sessionDir));
|
|
107
86
|
const inputsRaw = readFileOrNull((0, _animus_ui_extract_session.analysisInputsPath)(sessionDir));
|
|
108
87
|
if (manifestRaw === null || inputsRaw === null) continue;
|
|
109
|
-
|
|
88
|
+
const engine = engineApiFor(key)();
|
|
89
|
+
if ((0, _animus_ui_extract_session.artifactHash)(engine, manifestRaw) !== c0.manifestHash || (0, _animus_ui_extract_session.artifactHash)(engine, inputsRaw) !== c0.inputsHash) continue;
|
|
110
90
|
if (readFileOrNull(commitPath) !== c0raw) continue;
|
|
111
91
|
let inputs;
|
|
112
92
|
let fileHashes;
|
|
@@ -122,8 +102,7 @@ function hydrateSession(key, sessionDir, sessionId) {
|
|
|
122
102
|
} catch {
|
|
123
103
|
return { kind: "torn" };
|
|
124
104
|
}
|
|
125
|
-
const
|
|
126
|
-
const manifestJson = analyzeProject(...(0, _animus_ui_extract_pipeline.buildAnalyzeProjectArgs)(inputs));
|
|
105
|
+
const manifestJson = engine.analyzeProject(...(0, _animus_ui_extract_pipeline.buildAnalyzeProjectArgs)(inputs));
|
|
127
106
|
hydrations.set(buildId, {
|
|
128
107
|
commitKey,
|
|
129
108
|
manifestJson,
|
|
@@ -18,7 +18,7 @@ type LoaderCallback = (err: Error | null, content?: string) => void;
|
|
|
18
18
|
type LoaderContext = LoaderContextBase<TurbopackLoaderOptions> & {
|
|
19
19
|
async?: () => LoaderCallback;
|
|
20
20
|
};
|
|
21
|
-
type LoaderEngineApi = () => Pick<EngineApi, 'analyzeProject' | 'transformFile'>;
|
|
21
|
+
type LoaderEngineApi = () => Pick<EngineApi, 'analyzeProject' | 'transformFile' | 'fingerprintBytes'>;
|
|
22
22
|
/** @internal test seam. */
|
|
23
23
|
export declare function __setTurbopackLoaderEngineApiForTests(api: LoaderEngineApi | null): void;
|
|
24
24
|
type LoaderFs = Pick<typeof nodeFs, 'readFileSync' | 'existsSync'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turbopack-loader.d.ts","sourceRoot":"","sources":["../src/turbopack-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"turbopack-loader.d.ts","sourceRoot":"","sources":["../src/turbopack-loader.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,MAAM,MAAM,IAAI,CAAC;AAU7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAEV,SAAS,EACV,MAAM,6BAA6B,CAAC;AAWrC;;;yEAGyE;AACzE,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;mBAEe;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAEpE,KAAK,aAAa,GAAG,iBAAiB,CAAC,sBAAsB,CAAC,GAAG;IAC/D,KAAK,CAAC,EAAE,MAAM,cAAc,CAAC;CAC9B,CAAC;AASF,KAAK,eAAe,GAAG,MAAM,IAAI,CAC/B,SAAS,EACT,gBAAgB,GAAG,eAAe,GAAG,kBAAkB,CACxD,CAAC;AAGF,2BAA2B;AAC3B,wBAAgB,qCAAqC,CACnD,GAAG,EAAE,eAAe,GAAG,IAAI,GAC1B,IAAI,CAEN;AAaD,KAAK,QAAQ,GAAG,IAAI,CAAC,OAAO,MAAM,EAAE,cAAc,GAAG,YAAY,CAAC,CAAC;AAGnE,2BAA2B;AAC3B,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAExE;AAcD;oBACoB;AACpB,wBAAgB,mCAAmC,IAAI,IAAI,CAI1D;AAwJD,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,IAAI,CAYN"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as isTurbopackDevelopment } from "./turbopack-config-
|
|
1
|
+
import { r as isTurbopackDevelopment } from "./turbopack-config-BOUPGkmi.mjs";
|
|
2
2
|
import { n as extensionLineage, r as transformWithManifest, t as extendedFiles } from "./loader-core-DU2uZEMQ.mjs";
|
|
3
3
|
import { AnimusConfigError, assertSupportedEngine, buildAnalyzeProjectArgs, contentHash, parseFilesJson } from "@animus-ui/extract/pipeline";
|
|
4
|
-
import { analysisCommitPath, analysisInputsPath, analysisStatusPath, engineHandle, manifestPath, readJsonEnvelope, replacementEpochPath, sessionArtifactDir, sessionKey } from "@animus-ui/extract/session";
|
|
4
|
+
import { analysisCommitPath, analysisInputsPath, analysisStatusPath, artifactHash, engineHandle, manifestPath, readJsonEnvelope, replacementEpochPath, sessionArtifactDir, sessionKey } from "@animus-ui/extract/session";
|
|
5
5
|
import * as nodeFs from "fs";
|
|
6
6
|
import { join, relative } from "path";
|
|
7
7
|
//#region src/turbopack-loader.ts
|
|
@@ -79,7 +79,8 @@ function hydrateSession(key, sessionDir, sessionId) {
|
|
|
79
79
|
const manifestRaw = readFileOrNull(manifestPath(sessionDir));
|
|
80
80
|
const inputsRaw = readFileOrNull(analysisInputsPath(sessionDir));
|
|
81
81
|
if (manifestRaw === null || inputsRaw === null) continue;
|
|
82
|
-
|
|
82
|
+
const engine = engineApiFor(key)();
|
|
83
|
+
if (artifactHash(engine, manifestRaw) !== c0.manifestHash || artifactHash(engine, inputsRaw) !== c0.inputsHash) continue;
|
|
83
84
|
if (readFileOrNull(commitPath) !== c0raw) continue;
|
|
84
85
|
let inputs;
|
|
85
86
|
let fileHashes;
|
|
@@ -95,8 +96,7 @@ function hydrateSession(key, sessionDir, sessionId) {
|
|
|
95
96
|
} catch {
|
|
96
97
|
return { kind: "torn" };
|
|
97
98
|
}
|
|
98
|
-
const
|
|
99
|
-
const manifestJson = analyzeProject(...buildAnalyzeProjectArgs(inputs));
|
|
99
|
+
const manifestJson = engine.analyzeProject(...buildAnalyzeProjectArgs(inputs));
|
|
100
100
|
hydrations.set(buildId, {
|
|
101
101
|
commitKey,
|
|
102
102
|
manifestJson,
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClosedDynamicImport, DiagnosticLevels, StaticCssConfig } from '@animus-ui/extract/pipeline';
|
|
1
|
+
import type { AnimusQuarantineOptions, ClosedDynamicImport, FontPreloadEntry, DiagnosticLevels, StaticCssConfig } from '@animus-ui/extract/pipeline';
|
|
2
2
|
export interface AnimusNextOptions {
|
|
3
3
|
/** Path to a module exporting a SystemInstance from `@animus-ui/system`. */
|
|
4
4
|
system: string;
|
|
@@ -94,5 +94,20 @@ export interface AnimusNextOptions {
|
|
|
94
94
|
* the root, and `enclosingFunction`): each loads only what the build's
|
|
95
95
|
* own literal `import()`s load, an assumption the analysis records. */
|
|
96
96
|
closedDynamicImports?: ClosedDynamicImport[];
|
|
97
|
+
/** The font faces this app preloads, in place of each typed face's own
|
|
98
|
+
* `preload` flag, so a face declared once for every product preloads only
|
|
99
|
+
* where the app renders it: family names, or `{ family, weight?, style? }`
|
|
100
|
+
* (see `FontPreloadEntry`). `[]` preloads none. */
|
|
101
|
+
fontPreloads?: FontPreloadEntry[];
|
|
102
|
+
/**
|
|
103
|
+
* Load third-party stylesheets into `anm-vendor`, a layer below every
|
|
104
|
+
* Animus layer, so their normal rules never beat Animus's. Needs
|
|
105
|
+
* `@animus-ui/layergate` and webpack (`next build --webpack` on Next 16):
|
|
106
|
+
* Turbopack offers no CSS loader boundary for it. `sheets` are delivered
|
|
107
|
+
* with Animus's stylesheet, ahead of it; `dependencies` also covers `.css`
|
|
108
|
+
* your modules import from packages; `optOut` keeps a file's own rules
|
|
109
|
+
* outside the layer. App CSS and CSS Modules are left alone.
|
|
110
|
+
*/
|
|
111
|
+
quarantine?: AnimusQuarantineOptions;
|
|
97
112
|
}
|
|
98
113
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf;;;0DAGsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;6CAKyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;+EAC2E;IAC3E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;mDAG+C;IAC/C,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AG,IAAI,CAAA;KAAE,CAAC;IACtD;qEACiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;+EAC2E;IAC3E,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;sEAEkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;4EAEwE;IACxE,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C;;;wDAGoD;IACpD,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAClC;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC"}
|
package/dist/with-animus.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-animus.d.ts","sourceRoot":"","sources":["../src/with-animus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"with-animus.d.ts","sourceRoot":"","sources":["../src/with-animus.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,UAAU,IAAI,eAAe,EAC7B,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AAKxC,KAAK,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAE5D,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAC/C,OAA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e,IACxD,MAAM,SAAS,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,kBAAkB,CAAC;AAE1E,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,eAAe,IAAI,IAAI,CAClE,MAAM,EACN,SAAS,CACV,GAAG;IACF,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,MAAM,SAAS,eAAe,IAAI,IAAI,CAC1E,MAAM,EACN,WAAW,CACZ,GAAG;IACF,SAAS,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF;;;;4DAI4D;AAC5D,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,eAAe,IAAI,CAAC,CACjE,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,GAC9C,WAAW,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;AAUjD,wBAAgB,UAAU,CACxB,OAAO,EAAE,iBAAiB,GACzB,CAAC,MAAM,SAAS,eAAe,EAChC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,KAChC,iBAAiB,CAAC,MAAM,CAAC,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAgU3D;AASD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,MAAM,GACd,IAAI,CASN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/next-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "Animus static CSS extraction for Next.js (webpack)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animus",
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
31
|
"default": "./dist/index.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./font-preloads": {
|
|
34
|
+
"types": "./dist/font-preloads.d.ts",
|
|
35
|
+
"default": "./dist/font-preloads.cjs"
|
|
32
36
|
}
|
|
33
37
|
},
|
|
34
38
|
"publishConfig": {
|
|
@@ -40,15 +44,22 @@
|
|
|
40
44
|
"compile": "bun check"
|
|
41
45
|
},
|
|
42
46
|
"dependencies": {
|
|
43
|
-
"@animus-ui/extract": "0.1.
|
|
47
|
+
"@animus-ui/extract": "0.1.37"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
|
-
"@animus-ui/assertions": "0.1.
|
|
50
|
+
"@animus-ui/assertions": "0.1.37",
|
|
51
|
+
"@animus-ui/layergate": "0.1.37"
|
|
47
52
|
},
|
|
48
53
|
"peerDependencies": {
|
|
54
|
+
"@animus-ui/layergate": "0.1.37",
|
|
49
55
|
"next": ">=15 <17",
|
|
50
56
|
"webpack": ">=5 <6"
|
|
51
57
|
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@animus-ui/layergate": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
52
63
|
"engines": {
|
|
53
64
|
"node": ">=22.12.0"
|
|
54
65
|
}
|