@csszyx/unplugin 0.9.3 → 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.
@@ -1,25 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const node_module = require('node:module');
4
-
5
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
3
  function csszyxTurbopack(existing = {}, options = {}) {
7
- const { glob = "*.tsx", parserMode = "rust", safelistOutputFile, config } = options;
8
- const loaderOptions = { parserMode };
4
+ const { glob = "*.tsx", parserMode = "rust", safelistOutputFile } = options;
5
+ const config = options.config ?? { mangleVars: false };
6
+ const loaderOptions = { parserMode, config };
9
7
  if (safelistOutputFile !== void 0) {
10
8
  loaderOptions.safelistOutputFile = safelistOutputFile;
11
9
  }
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
10
  return {
24
11
  ...existing,
25
12
  rules: {
@@ -33,8 +20,7 @@ function csszyxTurbopack(existing = {}, options = {}) {
33
20
  ]
34
21
  // No `as` field — same-type .tsx -> .tsx transform.
35
22
  }
36
- },
37
- resolveAlias
23
+ }
38
24
  };
39
25
  }
40
26
 
@@ -1,3 +1,24 @@
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
+ */
1
22
  /** Options forwarded to the csszyx Next Turbopack loader. */
2
23
  interface CsszyxTurbopackOptions {
3
24
  /** Parser lane for the loader. Defaults to `'rust'` (the shipped default). */
@@ -1,3 +1,24 @@
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
+ */
1
22
  /** Options forwarded to the csszyx Next Turbopack loader. */
2
23
  interface CsszyxTurbopackOptions {
3
24
  /** Parser lane for the loader. Defaults to `'rust'` (the shipped default). */
@@ -1,22 +1,10 @@
1
- import { createRequire } from 'node:module';
2
-
3
1
  function csszyxTurbopack(existing = {}, options = {}) {
4
- const { glob = "*.tsx", parserMode = "rust", safelistOutputFile, config } = options;
5
- const loaderOptions = { parserMode };
2
+ const { glob = "*.tsx", parserMode = "rust", safelistOutputFile } = options;
3
+ const config = options.config ?? { mangleVars: false };
4
+ const loaderOptions = { parserMode, config };
6
5
  if (safelistOutputFile !== void 0) {
7
6
  loaderOptions.safelistOutputFile = safelistOutputFile;
8
7
  }
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
8
  return {
21
9
  ...existing,
22
10
  rules: {
@@ -30,8 +18,7 @@ function csszyxTurbopack(existing = {}, options = {}) {
30
18
  ]
31
19
  // No `as` field — same-type .tsx -> .tsx transform.
32
20
  }
33
- },
34
- resolveAlias
21
+ }
35
22
  };
36
23
  }
37
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/unplugin",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Vite and Webpack integration for csszyx",
5
5
  "keywords": [
6
6
  "csszyx",
@@ -117,14 +117,14 @@
117
117
  "postcss-value-parser": "^4.2.0",
118
118
  "proper-lockfile": "^4.1.2",
119
119
  "unplugin": "^1.10.1",
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"
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
125
  },
126
126
  "peerDependencies": {
127
- "@csszyx/runtime": "^0.9.3"
127
+ "@csszyx/runtime": "^0.9.4"
128
128
  },
129
129
  "devDependencies": {
130
130
  "@types/node": "^20.11.0",