@jk2908/cxx 0.1.6 → 0.1.8
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/LICENSE +20 -20
- package/README.md +58 -71
- package/package.json +89 -89
- package/src/cyrb53.ts +20 -19
- package/src/index.ts +11 -11
- package/src/inject.ts +54 -54
- package/src/next/cxx-loader.js +4 -4
- package/src/next/index.ts +56 -56
- package/src/vite-plugin-cxx/index.ts +15 -15
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -7
- package/dist/inject/index.cjs +0 -60
- package/dist/inject/index.d.ts +0 -8
- package/dist/inject/index.js +0 -58
- package/dist/next/cxx-loader.cjs +0 -9
- package/dist/next/cxx-loader.d.ts +0 -7
- package/dist/next/cxx-loader.js +0 -7
- package/dist/next/index.d.ts +0 -328
- package/dist/next/index.js +0 -55
- package/dist/vite-plugin-cxx/index.d.ts +0 -6
- package/dist/vite-plugin-cxx/index.js +0 -16
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Jerome Kenway
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jerome Kenway
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,71 +1,58 @@
|
|
|
1
|
-
cxx
|
|
2
|
-
|
|
3
|
-
library based on experiments with React 19 suspenseful style hoisting and deduping. `cxx` intakes CSS via a template literal arg and returns a three item tuple; the processed CSS, if configured (on by default) a CSS Modules exports object, and also optionally for usage, an id to pass to the href attribute of a style tag for deduping see [React docs](https://react.dev/reference/react-dom/components/style#noun-labs-1201738-(2)). The function actually just returns placeholders for the above items which will be replaced at build time. No string interpolation is supported within the CSS template tag
|
|
4
|
-
|
|
5
|
-
example usage:
|
|
6
|
-
In ui templates `cmp.tsx`:
|
|
7
|
-
```
|
|
8
|
-
import { cxx } from '@jk2908/cxx'
|
|
9
|
-
|
|
10
|
-
const [css, styles, href] = cxx`
|
|
11
|
-
.header {
|
|
12
|
-
display: flex;
|
|
13
|
-
}
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
function Cmp() {
|
|
17
|
-
return (
|
|
18
|
-
<header className={styles.header}>
|
|
19
|
-
...
|
|
20
|
-
|
|
21
|
-
<style href={href} precedence="medium">
|
|
22
|
-
{css}
|
|
23
|
-
</style>
|
|
24
|
-
</header>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
import { withCxx } from '@jk2908/cxx/next'
|
|
60
|
-
|
|
61
|
-
const nextConfig = {}
|
|
62
|
-
|
|
63
|
-
export default withCxx(nextConfig, { ...optional cxx config })
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
with inspiration from:
|
|
67
|
-
- https://github.com/bluskript/vite-plugin-inline-css-modules/
|
|
68
|
-
|
|
69
|
-
using:
|
|
70
|
-
- https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
|
|
71
|
-
- https://www.npmjs.com/package/lightningcss
|
|
1
|
+
cxx
|
|
2
|
+
|
|
3
|
+
library based on experiments with React 19 suspenseful style hoisting and deduping. `cxx` intakes CSS via a template literal arg and returns a three item tuple; the processed CSS, if configured (on by default) a CSS Modules exports object, and also optionally for usage, an id to pass to the href attribute of a style tag for deduping see [React docs](https://react.dev/reference/react-dom/components/style#noun-labs-1201738-(2)). The function actually just returns placeholders for the above items which will be replaced at build time. No string interpolation is supported within the CSS template tag.
|
|
4
|
+
|
|
5
|
+
example usage:
|
|
6
|
+
In ui templates `cmp.tsx`:
|
|
7
|
+
```
|
|
8
|
+
import { cxx } from '@jk2908/cxx'
|
|
9
|
+
|
|
10
|
+
const [css, styles, href] = cxx`
|
|
11
|
+
.header {
|
|
12
|
+
display: flex;
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
function Cmp() {
|
|
17
|
+
return (
|
|
18
|
+
<header className={styles.header}>
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
<style href={href} precedence="medium">
|
|
22
|
+
{css}
|
|
23
|
+
</style>
|
|
24
|
+
</header>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
CSS is transformed using [lightningcss](https://www.npmjs.com/package/lightningcss). There is access to the full lightningcss config.
|
|
30
|
+
|
|
31
|
+
vite `vite.config.ts`:
|
|
32
|
+
```
|
|
33
|
+
import cxx from '@jk2908/cxx/vite-plugin-cxx'
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
plugins: [react(), cxx({ ...optional cxx config })],
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// turn off default config
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
plugins: [cxx({
|
|
42
|
+
lightningcss: {
|
|
43
|
+
minify: false,
|
|
44
|
+
cssModules: false,
|
|
45
|
+
...other transform options
|
|
46
|
+
}
|
|
47
|
+
})]
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
next `next.config.ts`:
|
|
52
|
+
```
|
|
53
|
+
import { withCxx } from '@jk2908/cxx/next'
|
|
54
|
+
|
|
55
|
+
const nextConfig = {}
|
|
56
|
+
|
|
57
|
+
export default withCxx(nextConfig, { ...optional cxx config })
|
|
58
|
+
```
|
package/package.json
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@jk2908/cxx",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"author": "Jerome Kenway",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/jk2908/cxx.git"
|
|
9
|
-
},
|
|
10
|
-
"main": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "bunchee"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@biomejs/biome": "^1.8.3",
|
|
17
|
-
"@types/react": "latest",
|
|
18
|
-
"@types/react-dom": "latest",
|
|
19
|
-
"@types/webpack": "^5.28.5",
|
|
20
|
-
"bunchee": "^5.3.2",
|
|
21
|
-
"cross-env": "^7.0.3",
|
|
22
|
-
"lightningcss": "^1.27.0",
|
|
23
|
-
"next": "^15.0.0-canary.128",
|
|
24
|
-
"react": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
25
|
-
"react-dom": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
26
|
-
"typescript": "^5.5.4",
|
|
27
|
-
"vite": "^5.4.2"
|
|
28
|
-
},
|
|
29
|
-
"peerDependencies": {
|
|
30
|
-
"lightningcss": "^1.27.0",
|
|
31
|
-
"next": "^15.0.0-canary || ^15.0.0",
|
|
32
|
-
"react": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
33
|
-
"react-dom": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
34
|
-
"vite": "^4.0.0"
|
|
35
|
-
},
|
|
36
|
-
"exports": {
|
|
37
|
-
".": {
|
|
38
|
-
"types": "./dist/index.d.ts",
|
|
39
|
-
"default": "./dist/index.js"
|
|
40
|
-
},
|
|
41
|
-
"./inject": {
|
|
42
|
-
"types": "./dist/inject/index.d.ts",
|
|
43
|
-
"require": "./dist/inject/index.cjs",
|
|
44
|
-
"default": "./dist/inject/index.js"
|
|
45
|
-
},
|
|
46
|
-
"./next": {
|
|
47
|
-
"types": "./dist/next/index.d.ts",
|
|
48
|
-
"default": "./dist/next/index.js"
|
|
49
|
-
},
|
|
50
|
-
"./next/cxx-loader": {
|
|
51
|
-
"types": "./dist/next/cxx-loader.d.ts",
|
|
52
|
-
"require": "./dist/next/cxx-loader.cjs",
|
|
53
|
-
"default": "./dist/next/cxx-loader.js"
|
|
54
|
-
},
|
|
55
|
-
"./vite-plugin-cxx": {
|
|
56
|
-
"types": "./dist/vite-plugin-cxx/index.d.ts",
|
|
57
|
-
"default": "./dist/vite-plugin-cxx/index.js"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"bugs": {
|
|
61
|
-
"url": "https://github.com/jk2908/cxx/issues"
|
|
62
|
-
},
|
|
63
|
-
"description": "Utilities for generating styles in React 19",
|
|
64
|
-
"files": [
|
|
65
|
-
"dist",
|
|
66
|
-
"src"
|
|
67
|
-
],
|
|
68
|
-
"homepage": "https://github.com/jk2908/cxx#readme",
|
|
69
|
-
"keywords": [
|
|
70
|
-
"react",
|
|
71
|
-
"react19",
|
|
72
|
-
"css",
|
|
73
|
-
"css-in-js",
|
|
74
|
-
"vite-plugin",
|
|
75
|
-
"webpack-loader",
|
|
76
|
-
"lightningcss",
|
|
77
|
-
"next",
|
|
78
|
-
"vite"
|
|
79
|
-
],
|
|
80
|
-
"license": "MIT",
|
|
81
|
-
"peerDependenciesMeta": {
|
|
82
|
-
"next": {
|
|
83
|
-
"optional": true
|
|
84
|
-
},
|
|
85
|
-
"vite": {
|
|
86
|
-
"optional": true
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@jk2908/cxx",
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": "Jerome Kenway",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/jk2908/cxx.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "bunchee"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@biomejs/biome": "^1.8.3",
|
|
17
|
+
"@types/react": "latest",
|
|
18
|
+
"@types/react-dom": "latest",
|
|
19
|
+
"@types/webpack": "^5.28.5",
|
|
20
|
+
"bunchee": "^5.3.2",
|
|
21
|
+
"cross-env": "^7.0.3",
|
|
22
|
+
"lightningcss": "^1.27.0",
|
|
23
|
+
"next": "^15.0.0-canary.128",
|
|
24
|
+
"react": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
25
|
+
"react-dom": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
26
|
+
"typescript": "^5.5.4",
|
|
27
|
+
"vite": "^5.4.2"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"lightningcss": "^1.27.0",
|
|
31
|
+
"next": "^15.0.0-canary || ^15.0.0",
|
|
32
|
+
"react": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
33
|
+
"react-dom": "^19.0.0-rc || ^19.0.0-beta || ^19.0.0",
|
|
34
|
+
"vite": "^4.0.0"
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./inject": {
|
|
42
|
+
"types": "./dist/inject/index.d.ts",
|
|
43
|
+
"require": "./dist/inject/index.cjs",
|
|
44
|
+
"default": "./dist/inject/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./next": {
|
|
47
|
+
"types": "./dist/next/index.d.ts",
|
|
48
|
+
"default": "./dist/next/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./next/cxx-loader": {
|
|
51
|
+
"types": "./dist/next/cxx-loader.d.ts",
|
|
52
|
+
"require": "./dist/next/cxx-loader.cjs",
|
|
53
|
+
"default": "./dist/next/cxx-loader.js"
|
|
54
|
+
},
|
|
55
|
+
"./vite-plugin-cxx": {
|
|
56
|
+
"types": "./dist/vite-plugin-cxx/index.d.ts",
|
|
57
|
+
"default": "./dist/vite-plugin-cxx/index.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/jk2908/cxx/issues"
|
|
62
|
+
},
|
|
63
|
+
"description": "Utilities for generating styles in React 19",
|
|
64
|
+
"files": [
|
|
65
|
+
"dist",
|
|
66
|
+
"src"
|
|
67
|
+
],
|
|
68
|
+
"homepage": "https://github.com/jk2908/cxx#readme",
|
|
69
|
+
"keywords": [
|
|
70
|
+
"react",
|
|
71
|
+
"react19",
|
|
72
|
+
"css",
|
|
73
|
+
"css-in-js",
|
|
74
|
+
"vite-plugin",
|
|
75
|
+
"webpack-loader",
|
|
76
|
+
"lightningcss",
|
|
77
|
+
"next",
|
|
78
|
+
"vite"
|
|
79
|
+
],
|
|
80
|
+
"license": "MIT",
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"next": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"vite": {
|
|
86
|
+
"optional": true
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
package/src/cyrb53.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
// cyrb53 (c) 2018 bryc (github.com/bryc)
|
|
2
|
-
// https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
// cyrb53 (c) 2018 bryc (github.com/bryc)
|
|
2
|
+
// https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
|
|
3
|
+
|
|
4
|
+
export function cyrb53(str: string, seed = 0) {
|
|
5
|
+
let h1 = 0xdeadbeef ^ seed
|
|
6
|
+
let h2 = 0x41c6ce57 ^ seed
|
|
7
|
+
|
|
8
|
+
for (let i = 0, ch: number; i < str.length; i++) {
|
|
9
|
+
ch = str.charCodeAt(i)
|
|
10
|
+
h1 = Math.imul(h1 ^ ch, 2654435761)
|
|
11
|
+
h2 = Math.imul(h2 ^ ch, 1597334677)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)
|
|
15
|
+
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)
|
|
16
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)
|
|
17
|
+
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)
|
|
18
|
+
|
|
19
|
+
return 4294967296 * (2097151 & h2) + (h1 >>> 0)
|
|
20
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
declare module 'react' {
|
|
2
|
-
interface StyleHTMLAttributes<T> extends React.HTMLAttributes<T> {
|
|
3
|
-
href?: string
|
|
4
|
-
precedence?: 'low' | 'medium' | 'high'
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const cxx = (_: TemplateStringsArray): readonly ['', Record<string, string>, ''] => [
|
|
9
|
-
'',
|
|
10
|
-
{},
|
|
11
|
-
'',
|
|
1
|
+
declare module 'react' {
|
|
2
|
+
interface StyleHTMLAttributes<T> extends React.HTMLAttributes<T> {
|
|
3
|
+
href?: string
|
|
4
|
+
precedence?: 'low' | 'medium' | 'high'
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const cxx = (_: TemplateStringsArray): readonly ['', Record<string, string>, ''] => [
|
|
9
|
+
'',
|
|
10
|
+
{},
|
|
11
|
+
'',
|
|
12
12
|
]
|
package/src/inject.ts
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { cyrb53 } from './cyrb53'
|
|
2
|
-
|
|
3
|
-
import { type TransformOptions, type CustomAtRules, transform } from 'lightningcss'
|
|
4
|
-
|
|
5
|
-
const varMatch =
|
|
6
|
-
/(?:const|var|let)\s*\[(\w+|)\s*,?\s*(\w+|)\s*,?\s*(\w+|)\s*\]\s*=\s*cxx\s*`([\s\S]*?)`/gm
|
|
7
|
-
|
|
8
|
-
export type Config<C extends CustomAtRules = CustomAtRules> = {
|
|
9
|
-
lightningcss?: Partial<TransformOptions<C>>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const DEFAULT_CONFIG: Config = {
|
|
13
|
-
lightningcss: {
|
|
14
|
-
minify: true,
|
|
15
|
-
cssModules: true,
|
|
16
|
-
},
|
|
17
|
-
} as const
|
|
18
|
-
|
|
19
|
-
export function inject<C extends CustomAtRules = CustomAtRules>(
|
|
20
|
-
source: string,
|
|
21
|
-
id: string,
|
|
22
|
-
config: Config<C> = {},
|
|
23
|
-
) {
|
|
24
|
-
try {
|
|
25
|
-
const tmpl = source.replace(varMatch, (_: string, ...args: string[]) => {
|
|
26
|
-
const [varOne, varTwo, varThree, css] = args
|
|
27
|
-
|
|
28
|
-
const { code, exports } = transform({
|
|
29
|
-
...DEFAULT_CONFIG.lightningcss,
|
|
30
|
-
...config.lightningcss,
|
|
31
|
-
filename: id,
|
|
32
|
-
code: new TextEncoder().encode(css),
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const href = cyrb53([...Object.keys(exports ?? {}), id].join(''))
|
|
36
|
-
const classes = exports
|
|
37
|
-
? Object.fromEntries(Object.entries(exports).map(([key, value]) => [key, value.name]))
|
|
38
|
-
: {}
|
|
39
|
-
|
|
40
|
-
return [
|
|
41
|
-
varOne && `const ${varOne} = \`${code}\``,
|
|
42
|
-
varTwo && `const ${varTwo} = ${JSON.stringify(classes)}`,
|
|
43
|
-
varThree && `const ${varThree} = \`${href}\``,
|
|
44
|
-
]
|
|
45
|
-
.filter(Boolean)
|
|
46
|
-
.join('\n')
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
return tmpl
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.error('cxx error :(', err)
|
|
52
|
-
return source
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
import { cyrb53 } from './cyrb53'
|
|
2
|
+
|
|
3
|
+
import { type TransformOptions, type CustomAtRules, transform } from 'lightningcss'
|
|
4
|
+
|
|
5
|
+
const varMatch =
|
|
6
|
+
/(?:const|var|let)\s*\[(\w+|)\s*,?\s*(\w+|)\s*,?\s*(\w+|)\s*\]\s*=\s*cxx\s*`([\s\S]*?)`/gm
|
|
7
|
+
|
|
8
|
+
export type Config<C extends CustomAtRules = CustomAtRules> = {
|
|
9
|
+
lightningcss?: Partial<TransformOptions<C>>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DEFAULT_CONFIG: Config = {
|
|
13
|
+
lightningcss: {
|
|
14
|
+
minify: true,
|
|
15
|
+
cssModules: true,
|
|
16
|
+
},
|
|
17
|
+
} as const
|
|
18
|
+
|
|
19
|
+
export function inject<C extends CustomAtRules = CustomAtRules>(
|
|
20
|
+
source: string,
|
|
21
|
+
id: string,
|
|
22
|
+
config: Config<C> = {},
|
|
23
|
+
) {
|
|
24
|
+
try {
|
|
25
|
+
const tmpl = source.replace(varMatch, (_: string, ...args: string[]) => {
|
|
26
|
+
const [varOne, varTwo, varThree, css] = args
|
|
27
|
+
|
|
28
|
+
const { code, exports } = transform({
|
|
29
|
+
...DEFAULT_CONFIG.lightningcss,
|
|
30
|
+
...config.lightningcss,
|
|
31
|
+
filename: id,
|
|
32
|
+
code: new TextEncoder().encode(css),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const href = cyrb53([...Object.keys(exports ?? {}), id].join(''))
|
|
36
|
+
const classes = exports
|
|
37
|
+
? Object.fromEntries(Object.entries(exports).map(([key, value]) => [key, value.name]))
|
|
38
|
+
: {}
|
|
39
|
+
|
|
40
|
+
return [
|
|
41
|
+
varOne && `const ${varOne} = \`${code}\``,
|
|
42
|
+
varTwo && `const ${varTwo} = ${JSON.stringify(classes)}`,
|
|
43
|
+
varThree && `const ${varThree} = \`${href}\``,
|
|
44
|
+
]
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join('\n')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
return tmpl
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.error('cxx error :(', err)
|
|
52
|
+
return source
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/next/cxx-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject } from '../inject'
|
|
2
|
-
|
|
3
|
-
export default function loader(source) {
|
|
4
|
-
return inject(source, this.resourcePath, this.getOptions())
|
|
1
|
+
import { inject } from '../inject'
|
|
2
|
+
|
|
3
|
+
export default function loader(source) {
|
|
4
|
+
return inject(source, this.resourcePath, this.getOptions())
|
|
5
5
|
}
|
package/src/next/index.ts
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type { Configuration } from 'webpack'
|
|
4
|
-
import type { NextConfig } from 'next'
|
|
5
|
-
import type { WebpackConfigContext } from 'next/dist/server/config-shared'
|
|
6
|
-
|
|
7
|
-
import type { Config } from '../inject'
|
|
8
|
-
|
|
9
|
-
export function withCxx(nextConfig: NextConfig = {}, config: Config = {}) {
|
|
10
|
-
const pkg = require('next/package.json')
|
|
11
|
-
|
|
12
|
-
const IS_CANARY = pkg.version?.includes('canary') ?? false
|
|
13
|
-
const IS_TURBO = process.env.TURBOPACK === '1'
|
|
14
|
-
const TURBO_GLOB = '*.{tsx,jsx,ts,js}'
|
|
15
|
-
|
|
16
|
-
const loader = path.resolve(__dirname, `cxx-loader.${IS_TURBO ? 'cjs' : 'js'}`)
|
|
17
|
-
|
|
18
|
-
const turboConfig = {
|
|
19
|
-
...nextConfig.turbo,
|
|
20
|
-
rules: {
|
|
21
|
-
...nextConfig.turbo?.rules,
|
|
22
|
-
[TURBO_GLOB]: {
|
|
23
|
-
loaders: [
|
|
24
|
-
...(nextConfig.turbo?.rules?.[TURBO_GLOB]?.loaders ?? []),
|
|
25
|
-
{
|
|
26
|
-
loader,
|
|
27
|
-
options: config,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...nextConfig,
|
|
36
|
-
webpack(conf: Configuration, options: WebpackConfigContext) {
|
|
37
|
-
const resolvedWebpackConfig = (
|
|
38
|
-
typeof nextConfig?.webpack === 'function' ? nextConfig?.webpack(conf, options) : conf
|
|
39
|
-
) satisfies Configuration
|
|
40
|
-
|
|
41
|
-
resolvedWebpackConfig?.module?.rules?.push({
|
|
42
|
-
test: /\.(js|jsx|ts|tsx)$/,
|
|
43
|
-
exclude: /node_modules/,
|
|
44
|
-
use: {
|
|
45
|
-
loader,
|
|
46
|
-
options: config,
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
return resolvedWebpackConfig
|
|
51
|
-
},
|
|
52
|
-
...(IS_CANARY
|
|
53
|
-
? { experimental: { ...nextConfig?.experimental, turbo: turboConfig } }
|
|
54
|
-
: { turbo: turboConfig }),
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
import type { Configuration } from 'webpack'
|
|
4
|
+
import type { NextConfig } from 'next'
|
|
5
|
+
import type { WebpackConfigContext } from 'next/dist/server/config-shared'
|
|
6
|
+
|
|
7
|
+
import type { Config } from '../inject'
|
|
8
|
+
|
|
9
|
+
export function withCxx(nextConfig: NextConfig = {}, config: Config = {}) {
|
|
10
|
+
const pkg = require('next/package.json')
|
|
11
|
+
|
|
12
|
+
const IS_CANARY = pkg.version?.includes('canary') ?? false
|
|
13
|
+
const IS_TURBO = process.env.TURBOPACK === '1'
|
|
14
|
+
const TURBO_GLOB = '*.{tsx,jsx,ts,js}'
|
|
15
|
+
|
|
16
|
+
const loader = path.resolve(__dirname, `cxx-loader.${IS_TURBO ? 'cjs' : 'js'}`)
|
|
17
|
+
|
|
18
|
+
const turboConfig = {
|
|
19
|
+
...nextConfig.turbo,
|
|
20
|
+
rules: {
|
|
21
|
+
...nextConfig.turbo?.rules,
|
|
22
|
+
[TURBO_GLOB]: {
|
|
23
|
+
loaders: [
|
|
24
|
+
...(nextConfig.turbo?.rules?.[TURBO_GLOB]?.loaders ?? []),
|
|
25
|
+
{
|
|
26
|
+
loader,
|
|
27
|
+
options: config,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...nextConfig,
|
|
36
|
+
webpack(conf: Configuration, options: WebpackConfigContext) {
|
|
37
|
+
const resolvedWebpackConfig = (
|
|
38
|
+
typeof nextConfig?.webpack === 'function' ? nextConfig?.webpack(conf, options) : conf
|
|
39
|
+
) satisfies Configuration
|
|
40
|
+
|
|
41
|
+
resolvedWebpackConfig?.module?.rules?.push({
|
|
42
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
43
|
+
exclude: /node_modules/,
|
|
44
|
+
use: {
|
|
45
|
+
loader,
|
|
46
|
+
options: config,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return resolvedWebpackConfig
|
|
51
|
+
},
|
|
52
|
+
...(IS_CANARY
|
|
53
|
+
? { experimental: { ...nextConfig?.experimental, turbo: turboConfig } }
|
|
54
|
+
: { turbo: turboConfig }),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Plugin } from 'vite'
|
|
2
|
-
|
|
3
|
-
import { inject, type Config } from '../inject'
|
|
4
|
-
|
|
5
|
-
export default function vitePluginCxx(config?: Config): Plugin {
|
|
6
|
-
return {
|
|
7
|
-
name: 'cxx',
|
|
8
|
-
enforce: 'pre',
|
|
9
|
-
transform(code, id) {
|
|
10
|
-
return {
|
|
11
|
-
code: inject(code, id, config),
|
|
12
|
-
map: null
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import type { Plugin } from 'vite'
|
|
2
|
+
|
|
3
|
+
import { inject, type Config } from '../inject'
|
|
4
|
+
|
|
5
|
+
export default function vitePluginCxx(config?: Config): Plugin {
|
|
6
|
+
return {
|
|
7
|
+
name: 'cxx',
|
|
8
|
+
enforce: 'pre',
|
|
9
|
+
transform(code, id) {
|
|
10
|
+
return {
|
|
11
|
+
code: inject(code, id, config),
|
|
12
|
+
map: null
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
16
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare module 'react' {
|
|
2
|
-
interface StyleHTMLAttributes<T> extends React.HTMLAttributes<T> {
|
|
3
|
-
href?: string;
|
|
4
|
-
precedence?: 'low' | 'medium' | 'high';
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
declare const cxx: (_: TemplateStringsArray) => readonly ["", Record<string, string>, ""];
|
|
8
|
-
|
|
9
|
-
export { cxx };
|
package/dist/index.js
DELETED
package/dist/inject/index.cjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
|
|
3
|
-
var lightningcss = require('lightningcss');
|
|
4
|
-
|
|
5
|
-
// cyrb53 (c) 2018 bryc (github.com/bryc)
|
|
6
|
-
// https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
|
|
7
|
-
function cyrb53(str, seed = 0) {
|
|
8
|
-
let h1 = 0xdeadbeef ^ seed;
|
|
9
|
-
let h2 = 0x41c6ce57 ^ seed;
|
|
10
|
-
for(let i = 0, ch; i < str.length; i++){
|
|
11
|
-
ch = str.charCodeAt(i);
|
|
12
|
-
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
13
|
-
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
14
|
-
}
|
|
15
|
-
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
|
|
16
|
-
h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
17
|
-
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
|
|
18
|
-
h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
19
|
-
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const varMatch = /(?:const|var|let)\s*\[(\w+|)\s*,?\s*(\w+|)\s*,?\s*(\w+|)\s*\]\s*=\s*cxx\s*`([\s\S]*?)`/gm;
|
|
23
|
-
const DEFAULT_CONFIG = {
|
|
24
|
-
lightningcss: {
|
|
25
|
-
minify: true,
|
|
26
|
-
cssModules: true
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
function inject(source, id, config = {}) {
|
|
30
|
-
try {
|
|
31
|
-
const tmpl = source.replace(varMatch, (_, ...args)=>{
|
|
32
|
-
const [varOne, varTwo, varThree, css] = args;
|
|
33
|
-
const { code, exports } = lightningcss.transform({
|
|
34
|
-
...DEFAULT_CONFIG.lightningcss,
|
|
35
|
-
...config.lightningcss,
|
|
36
|
-
filename: id,
|
|
37
|
-
code: Buffer.from(css)
|
|
38
|
-
});
|
|
39
|
-
const href = cyrb53([
|
|
40
|
-
...Object.keys(exports ?? {}),
|
|
41
|
-
id
|
|
42
|
-
].join(''));
|
|
43
|
-
const classes = exports ? Object.fromEntries(Object.entries(exports).map(([key, value])=>[
|
|
44
|
-
key,
|
|
45
|
-
value.name
|
|
46
|
-
])) : {};
|
|
47
|
-
return [
|
|
48
|
-
varOne && `const ${varOne} = \`${code}\``,
|
|
49
|
-
varTwo && `const ${varTwo} = ${JSON.stringify(classes)}`,
|
|
50
|
-
varThree && `const ${varThree} = \`${href}\``
|
|
51
|
-
].filter(Boolean).join('\n');
|
|
52
|
-
});
|
|
53
|
-
return tmpl;
|
|
54
|
-
} catch (err) {
|
|
55
|
-
console.error('cxx error :(', err);
|
|
56
|
-
return source;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
exports.inject = inject;
|
package/dist/inject/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CustomAtRules, TransformOptions } from 'lightningcss';
|
|
2
|
-
|
|
3
|
-
type Config<C extends CustomAtRules = CustomAtRules> = {
|
|
4
|
-
lightningcss?: Partial<TransformOptions<C>>;
|
|
5
|
-
};
|
|
6
|
-
declare function inject<C extends CustomAtRules = CustomAtRules>(source: string, id: string, config?: Config<C>): string;
|
|
7
|
-
|
|
8
|
-
export { type Config, inject };
|
package/dist/inject/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { transform } from 'lightningcss';
|
|
2
|
-
|
|
3
|
-
// cyrb53 (c) 2018 bryc (github.com/bryc)
|
|
4
|
-
// https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js
|
|
5
|
-
function cyrb53(str, seed = 0) {
|
|
6
|
-
let h1 = 0xdeadbeef ^ seed;
|
|
7
|
-
let h2 = 0x41c6ce57 ^ seed;
|
|
8
|
-
for(let i = 0, ch; i < str.length; i++){
|
|
9
|
-
ch = str.charCodeAt(i);
|
|
10
|
-
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
11
|
-
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
12
|
-
}
|
|
13
|
-
h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
|
|
14
|
-
h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
|
|
15
|
-
h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
|
|
16
|
-
h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
|
|
17
|
-
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const varMatch = /(?:const|var|let)\s*\[(\w+|)\s*,?\s*(\w+|)\s*,?\s*(\w+|)\s*\]\s*=\s*cxx\s*`([\s\S]*?)`/gm;
|
|
21
|
-
const DEFAULT_CONFIG = {
|
|
22
|
-
lightningcss: {
|
|
23
|
-
minify: true,
|
|
24
|
-
cssModules: true
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
function inject(source, id, config = {}) {
|
|
28
|
-
try {
|
|
29
|
-
const tmpl = source.replace(varMatch, (_, ...args)=>{
|
|
30
|
-
const [varOne, varTwo, varThree, css] = args;
|
|
31
|
-
const { code, exports } = transform({
|
|
32
|
-
...DEFAULT_CONFIG.lightningcss,
|
|
33
|
-
...config.lightningcss,
|
|
34
|
-
filename: id,
|
|
35
|
-
code: Buffer.from(css)
|
|
36
|
-
});
|
|
37
|
-
const href = cyrb53([
|
|
38
|
-
...Object.keys(exports ?? {}),
|
|
39
|
-
id
|
|
40
|
-
].join(''));
|
|
41
|
-
const classes = exports ? Object.fromEntries(Object.entries(exports).map(([key, value])=>[
|
|
42
|
-
key,
|
|
43
|
-
value.name
|
|
44
|
-
])) : {};
|
|
45
|
-
return [
|
|
46
|
-
varOne && `const ${varOne} = \`${code}\``,
|
|
47
|
-
varTwo && `const ${varTwo} = ${JSON.stringify(classes)}`,
|
|
48
|
-
varThree && `const ${varThree} = \`${href}\``
|
|
49
|
-
].filter(Boolean).join('\n');
|
|
50
|
-
});
|
|
51
|
-
return tmpl;
|
|
52
|
-
} catch (err) {
|
|
53
|
-
console.error('cxx error :(', err);
|
|
54
|
-
return source;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { inject };
|
package/dist/next/cxx-loader.cjs
DELETED
package/dist/next/cxx-loader.js
DELETED
package/dist/next/index.d.ts
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import * as next_dist_shared_lib_image_config from 'next/dist/shared/lib/image-config';
|
|
2
|
-
import * as next_dist_lib_load_custom_routes from 'next/dist/lib/load-custom-routes';
|
|
3
|
-
import * as next_dist_server_config_shared from 'next/dist/server/config-shared';
|
|
4
|
-
import { WebpackConfigContext } from 'next/dist/server/config-shared';
|
|
5
|
-
import * as next_dist_cli_next_test from 'next/dist/cli/next-test';
|
|
6
|
-
import * as next from 'next';
|
|
7
|
-
import { NextConfig } from 'next';
|
|
8
|
-
import * as next_dist_server_lib_experimental_ppr from 'next/dist/server/lib/experimental/ppr';
|
|
9
|
-
import * as next_dist_shared_lib_utils from 'next/dist/shared/lib/utils';
|
|
10
|
-
import * as next_dist_build_webpack_plugins_subresource_integrity_plugin from 'next/dist/build/webpack/plugins/subresource-integrity-plugin';
|
|
11
|
-
import * as next_dist_compiled_webpack_webpack from 'next/dist/compiled/webpack/webpack';
|
|
12
|
-
import * as next_dist_server_lib_revalidate from 'next/dist/server/lib/revalidate';
|
|
13
|
-
import { Configuration } from 'webpack';
|
|
14
|
-
import { Config } from '../inject/index.js';
|
|
15
|
-
|
|
16
|
-
declare function withCxx(nextConfig?: NextConfig, config?: Config): {
|
|
17
|
-
experimental: {
|
|
18
|
-
turbo: any;
|
|
19
|
-
flyingShuttle?: boolean;
|
|
20
|
-
prerenderEarlyExit?: boolean;
|
|
21
|
-
linkNoTouchStart?: boolean;
|
|
22
|
-
caseSensitiveRoutes?: boolean;
|
|
23
|
-
appDocumentPreloading?: boolean;
|
|
24
|
-
preloadEntriesOnStart?: boolean;
|
|
25
|
-
strictNextHead?: boolean;
|
|
26
|
-
clientRouterFilter?: boolean;
|
|
27
|
-
clientRouterFilterRedirects?: boolean;
|
|
28
|
-
staleTimes?: {
|
|
29
|
-
dynamic?: number;
|
|
30
|
-
static?: number;
|
|
31
|
-
};
|
|
32
|
-
clientRouterFilterAllowedRate?: number;
|
|
33
|
-
externalMiddlewareRewritesResolve?: boolean;
|
|
34
|
-
extensionAlias?: Record<string, any>;
|
|
35
|
-
allowedRevalidateHeaderKeys?: string[];
|
|
36
|
-
fetchCacheKeyPrefix?: string;
|
|
37
|
-
optimisticClientCache?: boolean;
|
|
38
|
-
swrDelta?: next_dist_server_lib_revalidate.SwrDelta;
|
|
39
|
-
middlewarePrefetch?: "strict" | "flexible";
|
|
40
|
-
manualClientBasePath?: boolean;
|
|
41
|
-
cssChunking?: "strict" | "loose";
|
|
42
|
-
disablePostcssPresetEnv?: boolean;
|
|
43
|
-
cpus?: number;
|
|
44
|
-
memoryBasedWorkersCount?: boolean;
|
|
45
|
-
proxyTimeout?: number;
|
|
46
|
-
isrFlushToDisk?: boolean;
|
|
47
|
-
workerThreads?: boolean;
|
|
48
|
-
optimizeCss?: boolean | Record<string, unknown>;
|
|
49
|
-
nextScriptWorkers?: boolean;
|
|
50
|
-
scrollRestoration?: boolean;
|
|
51
|
-
externalDir?: boolean;
|
|
52
|
-
amp?: {
|
|
53
|
-
optimizer?: any;
|
|
54
|
-
validator?: string;
|
|
55
|
-
skipValidation?: boolean;
|
|
56
|
-
};
|
|
57
|
-
disableOptimizedLoading?: boolean;
|
|
58
|
-
gzipSize?: boolean;
|
|
59
|
-
craCompat?: boolean;
|
|
60
|
-
esmExternals?: boolean | "loose";
|
|
61
|
-
fullySpecified?: boolean;
|
|
62
|
-
urlImports?: NonNullable<next_dist_compiled_webpack_webpack.webpack.Configuration["experiments"]>["buildHttp"];
|
|
63
|
-
outputFileTracingRoot?: string;
|
|
64
|
-
outputFileTracingExcludes?: Record<string, string[]>;
|
|
65
|
-
outputFileTracingIgnores?: string[];
|
|
66
|
-
outputFileTracingIncludes?: Record<string, string[]>;
|
|
67
|
-
swcTraceProfiling?: boolean;
|
|
68
|
-
forceSwcTransforms?: boolean;
|
|
69
|
-
swcPlugins?: Array<[string, Record<string, unknown>]>;
|
|
70
|
-
largePageDataBytes?: number;
|
|
71
|
-
fallbackNodePolyfills?: false;
|
|
72
|
-
sri?: {
|
|
73
|
-
algorithm?: next_dist_build_webpack_plugins_subresource_integrity_plugin.SubresourceIntegrityAlgorithm;
|
|
74
|
-
};
|
|
75
|
-
adjustFontFallbacks?: boolean;
|
|
76
|
-
adjustFontFallbacksWithSizeAdjust?: boolean;
|
|
77
|
-
webVitalsAttribution?: Array<typeof next_dist_shared_lib_utils.WEB_VITALS[number]>;
|
|
78
|
-
optimizePackageImports?: string[];
|
|
79
|
-
optimizeServerReact?: boolean;
|
|
80
|
-
turbotrace?: {
|
|
81
|
-
logLevel?: "bug" | "fatal" | "error" | "warning" | "hint" | "note" | "suggestions" | "info";
|
|
82
|
-
logDetail?: boolean;
|
|
83
|
-
logAll?: boolean;
|
|
84
|
-
contextDirectory?: string;
|
|
85
|
-
processCwd?: string;
|
|
86
|
-
memoryLimit?: number;
|
|
87
|
-
};
|
|
88
|
-
mdxRs?: boolean | {
|
|
89
|
-
development?: boolean;
|
|
90
|
-
jsx?: boolean;
|
|
91
|
-
jsxRuntime?: string;
|
|
92
|
-
jsxImportSource?: string;
|
|
93
|
-
providerImportSource?: string;
|
|
94
|
-
mdxType?: "gfm" | "commonmark";
|
|
95
|
-
};
|
|
96
|
-
typedRoutes?: boolean;
|
|
97
|
-
parallelServerCompiles?: boolean;
|
|
98
|
-
parallelServerBuildTraces?: boolean;
|
|
99
|
-
webpackBuildWorker?: boolean;
|
|
100
|
-
webpackMemoryOptimizations?: boolean;
|
|
101
|
-
instrumentationHook?: boolean;
|
|
102
|
-
clientTraceMetadata?: string[];
|
|
103
|
-
ppr?: next_dist_server_lib_experimental_ppr.ExperimentalPPRConfig;
|
|
104
|
-
taint?: boolean;
|
|
105
|
-
serverActions?: {
|
|
106
|
-
bodySizeLimit?: next.SizeLimit;
|
|
107
|
-
allowedOrigins?: string[];
|
|
108
|
-
};
|
|
109
|
-
serverMinification?: boolean;
|
|
110
|
-
serverSourceMaps?: boolean;
|
|
111
|
-
staticWorkerRequestDeduping?: boolean;
|
|
112
|
-
useWasmBinary?: boolean;
|
|
113
|
-
useLightningcss?: boolean;
|
|
114
|
-
useEarlyImport?: boolean;
|
|
115
|
-
testProxy?: boolean;
|
|
116
|
-
defaultTestRunner?: next_dist_cli_next_test.SupportedTestRunners;
|
|
117
|
-
allowDevelopmentBuild?: true;
|
|
118
|
-
bundlePagesExternals?: boolean;
|
|
119
|
-
serverComponentsExternalPackages?: string[];
|
|
120
|
-
reactCompiler?: boolean | next_dist_server_config_shared.ReactCompilerOptions;
|
|
121
|
-
after?: boolean;
|
|
122
|
-
};
|
|
123
|
-
webpack(conf: Configuration, options: WebpackConfigContext): any;
|
|
124
|
-
exportPathMap?: (defaultMap: next_dist_server_config_shared.ExportPathMap, ctx: {
|
|
125
|
-
dev: boolean;
|
|
126
|
-
dir: string;
|
|
127
|
-
outDir: string | null;
|
|
128
|
-
distDir: string;
|
|
129
|
-
buildId: string;
|
|
130
|
-
}) => Promise<next_dist_server_config_shared.ExportPathMap> | next_dist_server_config_shared.ExportPathMap;
|
|
131
|
-
i18n?: next_dist_server_config_shared.I18NConfig | null;
|
|
132
|
-
eslint?: next_dist_server_config_shared.ESLintConfig;
|
|
133
|
-
typescript?: next_dist_server_config_shared.TypeScriptConfig;
|
|
134
|
-
headers?: () => Promise<next_dist_lib_load_custom_routes.Header[]>;
|
|
135
|
-
rewrites?: () => Promise<next_dist_lib_load_custom_routes.Rewrite[] | {
|
|
136
|
-
beforeFiles: next_dist_lib_load_custom_routes.Rewrite[];
|
|
137
|
-
afterFiles: next_dist_lib_load_custom_routes.Rewrite[];
|
|
138
|
-
fallback: next_dist_lib_load_custom_routes.Rewrite[];
|
|
139
|
-
}>;
|
|
140
|
-
redirects?: () => Promise<next_dist_lib_load_custom_routes.Redirect[]>;
|
|
141
|
-
excludeDefaultMomentLocales?: boolean;
|
|
142
|
-
trailingSlash?: boolean;
|
|
143
|
-
env?: Record<string, string | undefined>;
|
|
144
|
-
distDir?: string;
|
|
145
|
-
cleanDistDir?: boolean;
|
|
146
|
-
assetPrefix?: string;
|
|
147
|
-
cacheHandler?: string | undefined;
|
|
148
|
-
cacheMaxMemorySize?: number;
|
|
149
|
-
useFileSystemPublicRoutes?: boolean;
|
|
150
|
-
generateBuildId?: () => string | null | Promise<string | null>;
|
|
151
|
-
generateEtags?: boolean;
|
|
152
|
-
pageExtensions?: string[];
|
|
153
|
-
compress?: boolean;
|
|
154
|
-
poweredByHeader?: boolean;
|
|
155
|
-
images?: next_dist_shared_lib_image_config.ImageConfig;
|
|
156
|
-
devIndicators?: {
|
|
157
|
-
buildActivity?: boolean;
|
|
158
|
-
buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
159
|
-
};
|
|
160
|
-
onDemandEntries?: {
|
|
161
|
-
maxInactiveAge?: number;
|
|
162
|
-
pagesBufferLength?: number;
|
|
163
|
-
};
|
|
164
|
-
amp?: {
|
|
165
|
-
canonicalBase?: string;
|
|
166
|
-
};
|
|
167
|
-
deploymentId?: string;
|
|
168
|
-
basePath?: string;
|
|
169
|
-
sassOptions?: {
|
|
170
|
-
[key: string]: any;
|
|
171
|
-
};
|
|
172
|
-
productionBrowserSourceMaps?: boolean;
|
|
173
|
-
optimizeFonts?: boolean;
|
|
174
|
-
reactProductionProfiling?: boolean;
|
|
175
|
-
reactStrictMode?: boolean | null;
|
|
176
|
-
publicRuntimeConfig?: {
|
|
177
|
-
[key: string]: any;
|
|
178
|
-
};
|
|
179
|
-
serverRuntimeConfig?: {
|
|
180
|
-
[key: string]: any;
|
|
181
|
-
};
|
|
182
|
-
httpAgentOptions?: {
|
|
183
|
-
keepAlive?: boolean;
|
|
184
|
-
};
|
|
185
|
-
staticPageGenerationTimeout?: number;
|
|
186
|
-
crossOrigin?: "anonymous" | "use-credentials";
|
|
187
|
-
compiler?: {
|
|
188
|
-
reactRemoveProperties?: boolean | {
|
|
189
|
-
properties?: string[];
|
|
190
|
-
};
|
|
191
|
-
relay?: {
|
|
192
|
-
src: string;
|
|
193
|
-
artifactDirectory?: string;
|
|
194
|
-
language?: "typescript" | "javascript" | "flow";
|
|
195
|
-
eagerEsModules?: boolean;
|
|
196
|
-
};
|
|
197
|
-
removeConsole?: boolean | {
|
|
198
|
-
exclude?: string[];
|
|
199
|
-
};
|
|
200
|
-
styledComponents?: boolean | next_dist_server_config_shared.StyledComponentsConfig;
|
|
201
|
-
emotion?: boolean | next_dist_server_config_shared.EmotionConfig;
|
|
202
|
-
styledJsx?: boolean | {
|
|
203
|
-
useLightningcss?: boolean;
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
output?: "standalone" | "export";
|
|
207
|
-
transpilePackages?: string[];
|
|
208
|
-
skipMiddlewareUrlNormalize?: boolean;
|
|
209
|
-
skipTrailingSlashRedirect?: boolean;
|
|
210
|
-
modularizeImports?: Record<string, {
|
|
211
|
-
transform: string | Record<string, string>;
|
|
212
|
-
preventFullImport?: boolean;
|
|
213
|
-
skipDefaultConversion?: boolean;
|
|
214
|
-
}>;
|
|
215
|
-
logging?: {
|
|
216
|
-
fetches?: {
|
|
217
|
-
fullUrl?: boolean;
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
swrDelta?: next_dist_server_lib_revalidate.SwrDelta;
|
|
221
|
-
bundlePagesRouterDependencies?: boolean;
|
|
222
|
-
serverExternalPackages?: string[];
|
|
223
|
-
} | {
|
|
224
|
-
turbo: any;
|
|
225
|
-
webpack(conf: Configuration, options: WebpackConfigContext): any;
|
|
226
|
-
exportPathMap?: (defaultMap: next_dist_server_config_shared.ExportPathMap, ctx: {
|
|
227
|
-
dev: boolean;
|
|
228
|
-
dir: string;
|
|
229
|
-
outDir: string | null;
|
|
230
|
-
distDir: string;
|
|
231
|
-
buildId: string;
|
|
232
|
-
}) => Promise<next_dist_server_config_shared.ExportPathMap> | next_dist_server_config_shared.ExportPathMap;
|
|
233
|
-
i18n?: next_dist_server_config_shared.I18NConfig | null;
|
|
234
|
-
eslint?: next_dist_server_config_shared.ESLintConfig;
|
|
235
|
-
typescript?: next_dist_server_config_shared.TypeScriptConfig;
|
|
236
|
-
headers?: () => Promise<next_dist_lib_load_custom_routes.Header[]>;
|
|
237
|
-
rewrites?: () => Promise<next_dist_lib_load_custom_routes.Rewrite[] | {
|
|
238
|
-
beforeFiles: next_dist_lib_load_custom_routes.Rewrite[];
|
|
239
|
-
afterFiles: next_dist_lib_load_custom_routes.Rewrite[];
|
|
240
|
-
fallback: next_dist_lib_load_custom_routes.Rewrite[];
|
|
241
|
-
}>;
|
|
242
|
-
redirects?: () => Promise<next_dist_lib_load_custom_routes.Redirect[]>;
|
|
243
|
-
excludeDefaultMomentLocales?: boolean;
|
|
244
|
-
trailingSlash?: boolean;
|
|
245
|
-
env?: Record<string, string | undefined>;
|
|
246
|
-
distDir?: string;
|
|
247
|
-
cleanDistDir?: boolean;
|
|
248
|
-
assetPrefix?: string;
|
|
249
|
-
cacheHandler?: string | undefined;
|
|
250
|
-
cacheMaxMemorySize?: number;
|
|
251
|
-
useFileSystemPublicRoutes?: boolean;
|
|
252
|
-
generateBuildId?: () => string | null | Promise<string | null>;
|
|
253
|
-
generateEtags?: boolean;
|
|
254
|
-
pageExtensions?: string[];
|
|
255
|
-
compress?: boolean;
|
|
256
|
-
poweredByHeader?: boolean;
|
|
257
|
-
images?: next_dist_shared_lib_image_config.ImageConfig;
|
|
258
|
-
devIndicators?: {
|
|
259
|
-
buildActivity?: boolean;
|
|
260
|
-
buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
261
|
-
};
|
|
262
|
-
onDemandEntries?: {
|
|
263
|
-
maxInactiveAge?: number;
|
|
264
|
-
pagesBufferLength?: number;
|
|
265
|
-
};
|
|
266
|
-
amp?: {
|
|
267
|
-
canonicalBase?: string;
|
|
268
|
-
};
|
|
269
|
-
deploymentId?: string;
|
|
270
|
-
basePath?: string;
|
|
271
|
-
sassOptions?: {
|
|
272
|
-
[key: string]: any;
|
|
273
|
-
};
|
|
274
|
-
productionBrowserSourceMaps?: boolean;
|
|
275
|
-
optimizeFonts?: boolean;
|
|
276
|
-
reactProductionProfiling?: boolean;
|
|
277
|
-
reactStrictMode?: boolean | null;
|
|
278
|
-
publicRuntimeConfig?: {
|
|
279
|
-
[key: string]: any;
|
|
280
|
-
};
|
|
281
|
-
serverRuntimeConfig?: {
|
|
282
|
-
[key: string]: any;
|
|
283
|
-
};
|
|
284
|
-
httpAgentOptions?: {
|
|
285
|
-
keepAlive?: boolean;
|
|
286
|
-
};
|
|
287
|
-
staticPageGenerationTimeout?: number;
|
|
288
|
-
crossOrigin?: "anonymous" | "use-credentials";
|
|
289
|
-
compiler?: {
|
|
290
|
-
reactRemoveProperties?: boolean | {
|
|
291
|
-
properties?: string[];
|
|
292
|
-
};
|
|
293
|
-
relay?: {
|
|
294
|
-
src: string;
|
|
295
|
-
artifactDirectory?: string;
|
|
296
|
-
language?: "typescript" | "javascript" | "flow";
|
|
297
|
-
eagerEsModules?: boolean;
|
|
298
|
-
};
|
|
299
|
-
removeConsole?: boolean | {
|
|
300
|
-
exclude?: string[];
|
|
301
|
-
};
|
|
302
|
-
styledComponents?: boolean | next_dist_server_config_shared.StyledComponentsConfig;
|
|
303
|
-
emotion?: boolean | next_dist_server_config_shared.EmotionConfig;
|
|
304
|
-
styledJsx?: boolean | {
|
|
305
|
-
useLightningcss?: boolean;
|
|
306
|
-
};
|
|
307
|
-
};
|
|
308
|
-
output?: "standalone" | "export";
|
|
309
|
-
transpilePackages?: string[];
|
|
310
|
-
skipMiddlewareUrlNormalize?: boolean;
|
|
311
|
-
skipTrailingSlashRedirect?: boolean;
|
|
312
|
-
modularizeImports?: Record<string, {
|
|
313
|
-
transform: string | Record<string, string>;
|
|
314
|
-
preventFullImport?: boolean;
|
|
315
|
-
skipDefaultConversion?: boolean;
|
|
316
|
-
}>;
|
|
317
|
-
logging?: {
|
|
318
|
-
fetches?: {
|
|
319
|
-
fullUrl?: boolean;
|
|
320
|
-
};
|
|
321
|
-
};
|
|
322
|
-
swrDelta?: next_dist_server_lib_revalidate.SwrDelta;
|
|
323
|
-
experimental?: next_dist_server_config_shared.ExperimentalConfig;
|
|
324
|
-
bundlePagesRouterDependencies?: boolean;
|
|
325
|
-
serverExternalPackages?: string[];
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
export { withCxx };
|
package/dist/next/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import __node_cjsPath from 'node:path';
|
|
2
|
-
import __node_cjsUrl from 'node:url';
|
|
3
|
-
import __node_cjsModule from 'node:module';
|
|
4
|
-
|
|
5
|
-
const __filename = __node_cjsUrl.fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = __node_cjsPath.dirname(__filename);
|
|
7
|
-
const require = __node_cjsModule.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
function withCxx(nextConfig = {}, config = {}) {
|
|
10
|
-
const pkg = require('next/package.json');
|
|
11
|
-
const IS_CANARY = pkg.version?.includes('canary') ?? false;
|
|
12
|
-
const IS_TURBO = process.env.TURBOPACK === '1';
|
|
13
|
-
const TURBO_GLOB = '*.{tsx,jsx,ts,js}';
|
|
14
|
-
const loader = __node_cjsPath.resolve(__dirname, `cxx-loader.${IS_TURBO ? 'cjs' : 'js'}`);
|
|
15
|
-
const turboConfig = {
|
|
16
|
-
...nextConfig.turbo,
|
|
17
|
-
rules: {
|
|
18
|
-
...nextConfig.turbo?.rules ?? {},
|
|
19
|
-
[TURBO_GLOB]: {
|
|
20
|
-
loaders: [
|
|
21
|
-
...nextConfig.turbo?.rules?.[TURBO_GLOB]?.loaders ?? [],
|
|
22
|
-
{
|
|
23
|
-
loader,
|
|
24
|
-
options: config
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
return {
|
|
31
|
-
...nextConfig,
|
|
32
|
-
webpack (conf, options) {
|
|
33
|
-
const resolvedWebpackConfig = typeof nextConfig?.webpack === 'function' ? nextConfig?.webpack(conf, options) : conf;
|
|
34
|
-
resolvedWebpackConfig?.module?.rules?.push({
|
|
35
|
-
test: /\.(js|jsx|ts|tsx)$/,
|
|
36
|
-
exclude: /node_modules/,
|
|
37
|
-
use: {
|
|
38
|
-
loader,
|
|
39
|
-
options: config
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return resolvedWebpackConfig;
|
|
43
|
-
},
|
|
44
|
-
...IS_CANARY ? {
|
|
45
|
-
experimental: {
|
|
46
|
-
...nextConfig?.experimental,
|
|
47
|
-
turbo: turboConfig
|
|
48
|
-
}
|
|
49
|
-
} : {
|
|
50
|
-
turbo: turboConfig
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { withCxx };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { inject } from '../inject/index.js';
|
|
2
|
-
|
|
3
|
-
function vitePluginCxx(config) {
|
|
4
|
-
return {
|
|
5
|
-
name: 'cxx',
|
|
6
|
-
enforce: 'pre',
|
|
7
|
-
transform (code, id) {
|
|
8
|
-
return {
|
|
9
|
-
code: inject(code, id, config),
|
|
10
|
-
map: null
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { vitePluginCxx as default };
|