@csszyx/unplugin 0.9.2 → 0.9.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/next-config.cjs +27 -0
- package/dist/next-config.d.cts +63 -0
- package/dist/next-config.d.mts +63 -0
- package/dist/next-config.mjs +25 -0
- package/package.json +19 -6
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function csszyxTurbopack(existing = {}, options = {}) {
|
|
4
|
+
const { glob = "*.tsx", parserMode = "rust", safelistOutputFile } = options;
|
|
5
|
+
const config = options.config ?? { mangleVars: false };
|
|
6
|
+
const loaderOptions = { parserMode, config };
|
|
7
|
+
if (safelistOutputFile !== void 0) {
|
|
8
|
+
loaderOptions.safelistOutputFile = safelistOutputFile;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
...existing,
|
|
12
|
+
rules: {
|
|
13
|
+
...existing.rules ?? {},
|
|
14
|
+
[glob]: {
|
|
15
|
+
loaders: [
|
|
16
|
+
{
|
|
17
|
+
loader: "@csszyx/unplugin/next-turbo-loader",
|
|
18
|
+
options: loaderOptions
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
// No `as` field — same-type .tsx -> .tsx transform.
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.csszyxTurbopack = csszyxTurbopack;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js Turbopack config helper for csszyx.
|
|
3
|
+
*
|
|
4
|
+
* Wires the `turbopack` block so apps avoid the Turbopack foot-guns:
|
|
5
|
+
*
|
|
6
|
+
* 1. The `*.tsx` loader rule must **not** set `as`. csszyx is a same-type
|
|
7
|
+
* `.tsx -> .tsx` transform; `as: '*.tsx'` makes the loader output re-match
|
|
8
|
+
* its own rule and Turbopack resolves imports to `./X.tsx.tsx`
|
|
9
|
+
* (`Module not found`). This helper omits `as`.
|
|
10
|
+
* 2. `config` defaults to `{ mangleVars: false }` to match what
|
|
11
|
+
* `csszyx next prebuild` bakes into the production manifest hash; a mismatch
|
|
12
|
+
* fails the loader's config-hash gate ("config hash changed").
|
|
13
|
+
*
|
|
14
|
+
* The transform also injects a bare `import { _szMerge } from '@csszyx/runtime'`.
|
|
15
|
+
* That cannot be fixed from here — a Turbopack `resolveAlias` to an absolute path
|
|
16
|
+
* is treated as project-relative and breaks — so **`@csszyx/runtime` must be a
|
|
17
|
+
* direct dependency of the app** (it is declared as a peer dependency; add it to
|
|
18
|
+
* your `package.json`). See the installation docs.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
/** Options forwarded to the csszyx Next Turbopack loader. */
|
|
23
|
+
interface CsszyxTurbopackOptions {
|
|
24
|
+
/** Parser lane for the loader. Defaults to `'rust'` (the shipped default). */
|
|
25
|
+
parserMode?: 'rust' | 'oxc';
|
|
26
|
+
/**
|
|
27
|
+
* Safelist HTML path Tailwind `@source` reads. Must match the
|
|
28
|
+
* `csszyx next prebuild --output-file` / `csszyx next watch` path.
|
|
29
|
+
*/
|
|
30
|
+
safelistOutputFile?: string;
|
|
31
|
+
/** Extra csszyx config forwarded to the loader (e.g. `{ mangleVars: false }`). */
|
|
32
|
+
config?: Record<string, unknown>;
|
|
33
|
+
/** Glob the loader applies to. Defaults to `'*.tsx'` (whole app). */
|
|
34
|
+
glob?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Minimal shape of a Next.js `turbopack` config block (only what we touch). */
|
|
37
|
+
interface TurbopackConfig {
|
|
38
|
+
rules?: Record<string, unknown>;
|
|
39
|
+
resolveAlias?: Record<string, string>;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Merge csszyx's Turbopack loader rule + runtime alias into an existing
|
|
44
|
+
* `turbopack` config, preserving the caller's own `rules` / `resolveAlias`.
|
|
45
|
+
*
|
|
46
|
+
* @param existing - the caller's current `turbopack` config (preserved + merged).
|
|
47
|
+
* @param options - csszyx loader options.
|
|
48
|
+
* @returns a `turbopack` config to assign to `next.config`'s `turbopack` field.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // next.config.mjs
|
|
52
|
+
* import { csszyxTurbopack } from '@csszyx/unplugin/next';
|
|
53
|
+
* export default {
|
|
54
|
+
* turbopack: csszyxTurbopack(
|
|
55
|
+
* { resolveAlias: { 'maplibre-gl': 'maplibre-gl/dist/maplibre-gl.js' } },
|
|
56
|
+
* { safelistOutputFile: '.csszyx/next-loader-classes.html' },
|
|
57
|
+
* ),
|
|
58
|
+
* };
|
|
59
|
+
*/
|
|
60
|
+
declare function csszyxTurbopack(existing?: TurbopackConfig, options?: CsszyxTurbopackOptions): TurbopackConfig;
|
|
61
|
+
|
|
62
|
+
export { csszyxTurbopack };
|
|
63
|
+
export type { CsszyxTurbopackOptions, TurbopackConfig };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js Turbopack config helper for csszyx.
|
|
3
|
+
*
|
|
4
|
+
* Wires the `turbopack` block so apps avoid the Turbopack foot-guns:
|
|
5
|
+
*
|
|
6
|
+
* 1. The `*.tsx` loader rule must **not** set `as`. csszyx is a same-type
|
|
7
|
+
* `.tsx -> .tsx` transform; `as: '*.tsx'` makes the loader output re-match
|
|
8
|
+
* its own rule and Turbopack resolves imports to `./X.tsx.tsx`
|
|
9
|
+
* (`Module not found`). This helper omits `as`.
|
|
10
|
+
* 2. `config` defaults to `{ mangleVars: false }` to match what
|
|
11
|
+
* `csszyx next prebuild` bakes into the production manifest hash; a mismatch
|
|
12
|
+
* fails the loader's config-hash gate ("config hash changed").
|
|
13
|
+
*
|
|
14
|
+
* The transform also injects a bare `import { _szMerge } from '@csszyx/runtime'`.
|
|
15
|
+
* That cannot be fixed from here — a Turbopack `resolveAlias` to an absolute path
|
|
16
|
+
* is treated as project-relative and breaks — so **`@csszyx/runtime` must be a
|
|
17
|
+
* direct dependency of the app** (it is declared as a peer dependency; add it to
|
|
18
|
+
* your `package.json`). See the installation docs.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
/** Options forwarded to the csszyx Next Turbopack loader. */
|
|
23
|
+
interface CsszyxTurbopackOptions {
|
|
24
|
+
/** Parser lane for the loader. Defaults to `'rust'` (the shipped default). */
|
|
25
|
+
parserMode?: 'rust' | 'oxc';
|
|
26
|
+
/**
|
|
27
|
+
* Safelist HTML path Tailwind `@source` reads. Must match the
|
|
28
|
+
* `csszyx next prebuild --output-file` / `csszyx next watch` path.
|
|
29
|
+
*/
|
|
30
|
+
safelistOutputFile?: string;
|
|
31
|
+
/** Extra csszyx config forwarded to the loader (e.g. `{ mangleVars: false }`). */
|
|
32
|
+
config?: Record<string, unknown>;
|
|
33
|
+
/** Glob the loader applies to. Defaults to `'*.tsx'` (whole app). */
|
|
34
|
+
glob?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Minimal shape of a Next.js `turbopack` config block (only what we touch). */
|
|
37
|
+
interface TurbopackConfig {
|
|
38
|
+
rules?: Record<string, unknown>;
|
|
39
|
+
resolveAlias?: Record<string, string>;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Merge csszyx's Turbopack loader rule + runtime alias into an existing
|
|
44
|
+
* `turbopack` config, preserving the caller's own `rules` / `resolveAlias`.
|
|
45
|
+
*
|
|
46
|
+
* @param existing - the caller's current `turbopack` config (preserved + merged).
|
|
47
|
+
* @param options - csszyx loader options.
|
|
48
|
+
* @returns a `turbopack` config to assign to `next.config`'s `turbopack` field.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // next.config.mjs
|
|
52
|
+
* import { csszyxTurbopack } from '@csszyx/unplugin/next';
|
|
53
|
+
* export default {
|
|
54
|
+
* turbopack: csszyxTurbopack(
|
|
55
|
+
* { resolveAlias: { 'maplibre-gl': 'maplibre-gl/dist/maplibre-gl.js' } },
|
|
56
|
+
* { safelistOutputFile: '.csszyx/next-loader-classes.html' },
|
|
57
|
+
* ),
|
|
58
|
+
* };
|
|
59
|
+
*/
|
|
60
|
+
declare function csszyxTurbopack(existing?: TurbopackConfig, options?: CsszyxTurbopackOptions): TurbopackConfig;
|
|
61
|
+
|
|
62
|
+
export { csszyxTurbopack };
|
|
63
|
+
export type { CsszyxTurbopackOptions, TurbopackConfig };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function csszyxTurbopack(existing = {}, options = {}) {
|
|
2
|
+
const { glob = "*.tsx", parserMode = "rust", safelistOutputFile } = options;
|
|
3
|
+
const config = options.config ?? { mangleVars: false };
|
|
4
|
+
const loaderOptions = { parserMode, config };
|
|
5
|
+
if (safelistOutputFile !== void 0) {
|
|
6
|
+
loaderOptions.safelistOutputFile = safelistOutputFile;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
...existing,
|
|
10
|
+
rules: {
|
|
11
|
+
...existing.rules ?? {},
|
|
12
|
+
[glob]: {
|
|
13
|
+
loaders: [
|
|
14
|
+
{
|
|
15
|
+
loader: "@csszyx/unplugin/next-turbo-loader",
|
|
16
|
+
options: loaderOptions
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
// No `as` field — same-type .tsx -> .tsx transform.
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { csszyxTurbopack };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/unplugin",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "Vite and Webpack integration for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -64,6 +64,16 @@
|
|
|
64
64
|
"default": "./dist/css-mangler.cjs"
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
+
"./next": {
|
|
68
|
+
"import": {
|
|
69
|
+
"types": "./dist/next-config.d.mts",
|
|
70
|
+
"default": "./dist/next-config.mjs"
|
|
71
|
+
},
|
|
72
|
+
"require": {
|
|
73
|
+
"types": "./dist/next-config.d.cts",
|
|
74
|
+
"default": "./dist/next-config.cjs"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
67
77
|
"./next-turbo-loader": {
|
|
68
78
|
"import": {
|
|
69
79
|
"types": "./dist/next-turbo-loader.d.mts",
|
|
@@ -107,11 +117,14 @@
|
|
|
107
117
|
"postcss-value-parser": "^4.2.0",
|
|
108
118
|
"proper-lockfile": "^4.1.2",
|
|
109
119
|
"unplugin": "^1.10.1",
|
|
110
|
-
"@csszyx/core": "0.9.
|
|
111
|
-
"@csszyx/compiler": "0.9.
|
|
112
|
-
"@csszyx/types": "0.9.
|
|
113
|
-
"@csszyx/vue-adapter": "0.9.
|
|
114
|
-
"@csszyx/svelte-adapter": "0.9.
|
|
120
|
+
"@csszyx/core": "0.9.4",
|
|
121
|
+
"@csszyx/compiler": "0.9.4",
|
|
122
|
+
"@csszyx/types": "0.9.4",
|
|
123
|
+
"@csszyx/vue-adapter": "0.9.4",
|
|
124
|
+
"@csszyx/svelte-adapter": "0.9.4"
|
|
125
|
+
},
|
|
126
|
+
"peerDependencies": {
|
|
127
|
+
"@csszyx/runtime": "^0.9.4"
|
|
115
128
|
},
|
|
116
129
|
"devDependencies": {
|
|
117
130
|
"@types/node": "^20.11.0",
|