@csszyx/unplugin 0.9.2 → 0.9.3

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.
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ const node_module = require('node:module');
4
+
5
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
+ function csszyxTurbopack(existing = {}, options = {}) {
7
+ const { glob = "*.tsx", parserMode = "rust", safelistOutputFile, config } = options;
8
+ const loaderOptions = { parserMode };
9
+ if (safelistOutputFile !== void 0) {
10
+ loaderOptions.safelistOutputFile = safelistOutputFile;
11
+ }
12
+ if (config !== void 0) {
13
+ loaderOptions.config = config;
14
+ }
15
+ const resolveAlias = { ...existing.resolveAlias ?? {} };
16
+ if (resolveAlias["@csszyx/runtime"] === void 0) {
17
+ try {
18
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next-config.cjs', document.baseURI).href)));
19
+ resolveAlias["@csszyx/runtime"] = require$1.resolve("@csszyx/runtime");
20
+ } catch {
21
+ }
22
+ }
23
+ return {
24
+ ...existing,
25
+ rules: {
26
+ ...existing.rules ?? {},
27
+ [glob]: {
28
+ loaders: [
29
+ {
30
+ loader: "@csszyx/unplugin/next-turbo-loader",
31
+ options: loaderOptions
32
+ }
33
+ ]
34
+ // No `as` field — same-type .tsx -> .tsx transform.
35
+ }
36
+ },
37
+ resolveAlias
38
+ };
39
+ }
40
+
41
+ exports.csszyxTurbopack = csszyxTurbopack;
@@ -0,0 +1,42 @@
1
+ /** Options forwarded to the csszyx Next Turbopack loader. */
2
+ interface CsszyxTurbopackOptions {
3
+ /** Parser lane for the loader. Defaults to `'rust'` (the shipped default). */
4
+ parserMode?: 'rust' | 'oxc';
5
+ /**
6
+ * Safelist HTML path Tailwind `@source` reads. Must match the
7
+ * `csszyx next prebuild --output-file` / `csszyx next watch` path.
8
+ */
9
+ safelistOutputFile?: string;
10
+ /** Extra csszyx config forwarded to the loader (e.g. `{ mangleVars: false }`). */
11
+ config?: Record<string, unknown>;
12
+ /** Glob the loader applies to. Defaults to `'*.tsx'` (whole app). */
13
+ glob?: string;
14
+ }
15
+ /** Minimal shape of a Next.js `turbopack` config block (only what we touch). */
16
+ interface TurbopackConfig {
17
+ rules?: Record<string, unknown>;
18
+ resolveAlias?: Record<string, string>;
19
+ [key: string]: unknown;
20
+ }
21
+ /**
22
+ * Merge csszyx's Turbopack loader rule + runtime alias into an existing
23
+ * `turbopack` config, preserving the caller's own `rules` / `resolveAlias`.
24
+ *
25
+ * @param existing - the caller's current `turbopack` config (preserved + merged).
26
+ * @param options - csszyx loader options.
27
+ * @returns a `turbopack` config to assign to `next.config`'s `turbopack` field.
28
+ *
29
+ * @example
30
+ * // next.config.mjs
31
+ * import { csszyxTurbopack } from '@csszyx/unplugin/next';
32
+ * export default {
33
+ * turbopack: csszyxTurbopack(
34
+ * { resolveAlias: { 'maplibre-gl': 'maplibre-gl/dist/maplibre-gl.js' } },
35
+ * { safelistOutputFile: '.csszyx/next-loader-classes.html' },
36
+ * ),
37
+ * };
38
+ */
39
+ declare function csszyxTurbopack(existing?: TurbopackConfig, options?: CsszyxTurbopackOptions): TurbopackConfig;
40
+
41
+ export { csszyxTurbopack };
42
+ export type { CsszyxTurbopackOptions, TurbopackConfig };
@@ -0,0 +1,42 @@
1
+ /** Options forwarded to the csszyx Next Turbopack loader. */
2
+ interface CsszyxTurbopackOptions {
3
+ /** Parser lane for the loader. Defaults to `'rust'` (the shipped default). */
4
+ parserMode?: 'rust' | 'oxc';
5
+ /**
6
+ * Safelist HTML path Tailwind `@source` reads. Must match the
7
+ * `csszyx next prebuild --output-file` / `csszyx next watch` path.
8
+ */
9
+ safelistOutputFile?: string;
10
+ /** Extra csszyx config forwarded to the loader (e.g. `{ mangleVars: false }`). */
11
+ config?: Record<string, unknown>;
12
+ /** Glob the loader applies to. Defaults to `'*.tsx'` (whole app). */
13
+ glob?: string;
14
+ }
15
+ /** Minimal shape of a Next.js `turbopack` config block (only what we touch). */
16
+ interface TurbopackConfig {
17
+ rules?: Record<string, unknown>;
18
+ resolveAlias?: Record<string, string>;
19
+ [key: string]: unknown;
20
+ }
21
+ /**
22
+ * Merge csszyx's Turbopack loader rule + runtime alias into an existing
23
+ * `turbopack` config, preserving the caller's own `rules` / `resolveAlias`.
24
+ *
25
+ * @param existing - the caller's current `turbopack` config (preserved + merged).
26
+ * @param options - csszyx loader options.
27
+ * @returns a `turbopack` config to assign to `next.config`'s `turbopack` field.
28
+ *
29
+ * @example
30
+ * // next.config.mjs
31
+ * import { csszyxTurbopack } from '@csszyx/unplugin/next';
32
+ * export default {
33
+ * turbopack: csszyxTurbopack(
34
+ * { resolveAlias: { 'maplibre-gl': 'maplibre-gl/dist/maplibre-gl.js' } },
35
+ * { safelistOutputFile: '.csszyx/next-loader-classes.html' },
36
+ * ),
37
+ * };
38
+ */
39
+ declare function csszyxTurbopack(existing?: TurbopackConfig, options?: CsszyxTurbopackOptions): TurbopackConfig;
40
+
41
+ export { csszyxTurbopack };
42
+ export type { CsszyxTurbopackOptions, TurbopackConfig };
@@ -0,0 +1,38 @@
1
+ import { createRequire } from 'node:module';
2
+
3
+ function csszyxTurbopack(existing = {}, options = {}) {
4
+ const { glob = "*.tsx", parserMode = "rust", safelistOutputFile, config } = options;
5
+ const loaderOptions = { parserMode };
6
+ if (safelistOutputFile !== void 0) {
7
+ loaderOptions.safelistOutputFile = safelistOutputFile;
8
+ }
9
+ if (config !== void 0) {
10
+ loaderOptions.config = config;
11
+ }
12
+ const resolveAlias = { ...existing.resolveAlias ?? {} };
13
+ if (resolveAlias["@csszyx/runtime"] === void 0) {
14
+ try {
15
+ const require = createRequire(import.meta.url);
16
+ resolveAlias["@csszyx/runtime"] = require.resolve("@csszyx/runtime");
17
+ } catch {
18
+ }
19
+ }
20
+ return {
21
+ ...existing,
22
+ rules: {
23
+ ...existing.rules ?? {},
24
+ [glob]: {
25
+ loaders: [
26
+ {
27
+ loader: "@csszyx/unplugin/next-turbo-loader",
28
+ options: loaderOptions
29
+ }
30
+ ]
31
+ // No `as` field — same-type .tsx -> .tsx transform.
32
+ }
33
+ },
34
+ resolveAlias
35
+ };
36
+ }
37
+
38
+ export { csszyxTurbopack };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/unplugin",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
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.2",
111
- "@csszyx/compiler": "0.9.2",
112
- "@csszyx/types": "0.9.2",
113
- "@csszyx/vue-adapter": "0.9.2",
114
- "@csszyx/svelte-adapter": "0.9.2"
120
+ "@csszyx/core": "0.9.3",
121
+ "@csszyx/vue-adapter": "0.9.3",
122
+ "@csszyx/compiler": "0.9.3",
123
+ "@csszyx/types": "0.9.3",
124
+ "@csszyx/svelte-adapter": "0.9.3"
125
+ },
126
+ "peerDependencies": {
127
+ "@csszyx/runtime": "^0.9.3"
115
128
  },
116
129
  "devDependencies": {
117
130
  "@types/node": "^20.11.0",