@tamagui/next-plugin 1.0.0-alpha.22 → 1.0.0-alpha.23
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/package.json +4 -5
- package/src/index.ts +0 -1
- package/src/withTamagui.ts +0 -203
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/next-plugin",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"typings": "types",
|
|
6
6
|
"main": "dist/cjs",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"module:jsx": "dist/jsx",
|
|
9
9
|
"files": [
|
|
10
10
|
"types",
|
|
11
|
-
"src",
|
|
12
11
|
"dist"
|
|
13
12
|
],
|
|
14
13
|
"scripts": {
|
|
@@ -18,12 +17,12 @@
|
|
|
18
17
|
"license": "MIT",
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"@tamagui/build": "^1.0.0-alpha.22",
|
|
21
|
-
"@tamagui/static": "^1.0.0-alpha.
|
|
20
|
+
"@tamagui/static": "^1.0.0-alpha.23",
|
|
22
21
|
"css-minimizer-webpack-plugin": "^3.1.3",
|
|
23
22
|
"esbuild-loader": "^2.16.0",
|
|
24
23
|
"next": "^11.1.2",
|
|
25
24
|
"next-compose-plugins": "^2.2.1",
|
|
26
|
-
"tamagui-loader": "^1.0.0-alpha.
|
|
25
|
+
"tamagui-loader": "^1.0.0-alpha.23"
|
|
27
26
|
},
|
|
28
27
|
"peerDependencies": {
|
|
29
28
|
"next": ">=11.0.0"
|
|
@@ -31,5 +30,5 @@
|
|
|
31
30
|
"publishConfig": {
|
|
32
31
|
"access": "public"
|
|
33
32
|
},
|
|
34
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "69fb1d82868a6525fee6b0750cb2113d88ffea79"
|
|
35
34
|
}
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './withTamagui'
|
package/src/withTamagui.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
|
|
3
|
-
import { TamaguiOptions } from '@tamagui/static'
|
|
4
|
-
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
|
|
5
|
-
import webpack from 'webpack'
|
|
6
|
-
|
|
7
|
-
export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
|
|
8
|
-
return (nextConfig: any = {}) => {
|
|
9
|
-
return Object.assign({}, nextConfig, {
|
|
10
|
-
webpack: (webpackConfig, options) => {
|
|
11
|
-
const { config, dev, isServer } = options
|
|
12
|
-
|
|
13
|
-
webpackConfig.resolve.alias = {
|
|
14
|
-
...(webpackConfig.resolve.alias || {}),
|
|
15
|
-
'react-native$': 'react-native-web',
|
|
16
|
-
'react-native-web/src/modules/normalizeColor': require.resolve(
|
|
17
|
-
'react-native-web/dist/cjs/modules/normalizeColor'
|
|
18
|
-
),
|
|
19
|
-
// fix mdx-bundler issue importing .js specifically
|
|
20
|
-
// 'react/jsx-runtime.js': require.resolve('react/jsx-runtime'),
|
|
21
|
-
'react/jsx-runtime': require.resolve('react/jsx-runtime'),
|
|
22
|
-
'react/jsx-dev-runtime': require.resolve('react/jsx-dev-runtime'),
|
|
23
|
-
react: require.resolve('react'),
|
|
24
|
-
'react-dom': require.resolve('react-dom'),
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
webpackConfig.plugins.push(
|
|
28
|
-
new webpack.DefinePlugin({
|
|
29
|
-
'process.env.TAMAGUI_TARGET': '"web"',
|
|
30
|
-
})
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
if (process.env.IGNORE_TS_CONFIG_PATHS) {
|
|
34
|
-
console.log('ignoring tsconfig paths, they mess up transpile')
|
|
35
|
-
delete webpackConfig.resolve.plugins[0].paths['@tamagui/*']
|
|
36
|
-
delete webpackConfig.resolve.plugins[0].paths['tamagui']
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// TODO document and make configurable
|
|
40
|
-
// replace minifier with css-minimizer-webpack-plugin which handles deduping atomic styles
|
|
41
|
-
const cssMin = webpackConfig.optimization.minimizer.find((x) =>
|
|
42
|
-
x.toString().includes('css-minimizer-plugin')
|
|
43
|
-
)
|
|
44
|
-
if (cssMin) {
|
|
45
|
-
webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(
|
|
46
|
-
cssMin.index,
|
|
47
|
-
1
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin())
|
|
51
|
-
|
|
52
|
-
if (!webpackConfig.resolve.extensions.includes('.web.js')) {
|
|
53
|
-
webpackConfig.resolve.extensions = ['.web.js', ...webpackConfig.resolve.extensions]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// look for compiled js with jsx intact as specified by module:jsx
|
|
57
|
-
webpackConfig.resolve.mainFields.unshift('module:jsx')
|
|
58
|
-
|
|
59
|
-
// why is it undefined on next11??? but it says using webpack5
|
|
60
|
-
const isWebpack5 = !!config.future.webpack5 || typeof config.webpack5 === 'undefined'
|
|
61
|
-
|
|
62
|
-
const includeModule = (context: string, request: string) => {
|
|
63
|
-
const fullPath = request[0] === '.' ? path.join(context, request) : request
|
|
64
|
-
if (/^\@?react-native-/.test(request)) {
|
|
65
|
-
return false
|
|
66
|
-
}
|
|
67
|
-
if (
|
|
68
|
-
fullPath.startsWith('react-native-web') ||
|
|
69
|
-
fullPath.includes('node_modules/react-native-web')
|
|
70
|
-
) {
|
|
71
|
-
return `commonjs ${fullPath}`
|
|
72
|
-
}
|
|
73
|
-
if (/^(react-dom|react)$/.test(fullPath)) {
|
|
74
|
-
return `commonjs ${fullPath}`
|
|
75
|
-
}
|
|
76
|
-
return true
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (isServer) {
|
|
80
|
-
// externalize react native things from bundle
|
|
81
|
-
webpackConfig.externals = [
|
|
82
|
-
...webpackConfig.externals.map((external) => {
|
|
83
|
-
if (typeof external !== 'function') {
|
|
84
|
-
return external
|
|
85
|
-
}
|
|
86
|
-
// only runs on server
|
|
87
|
-
if (isWebpack5) {
|
|
88
|
-
return (ctx, cb) => {
|
|
89
|
-
const res = includeModule(ctx.context, ctx.request)
|
|
90
|
-
if (typeof res === 'string') {
|
|
91
|
-
return cb(null, res)
|
|
92
|
-
}
|
|
93
|
-
if (res) {
|
|
94
|
-
return external(ctx, cb)
|
|
95
|
-
}
|
|
96
|
-
return cb()
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return (ctx, req, cb) => {
|
|
100
|
-
const res = includeModule(ctx, req)
|
|
101
|
-
if (typeof res === 'string') {
|
|
102
|
-
return cb(null, res)
|
|
103
|
-
}
|
|
104
|
-
if (res) {
|
|
105
|
-
return external(ctx, cb)
|
|
106
|
-
}
|
|
107
|
-
return cb()
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf)
|
|
114
|
-
|
|
115
|
-
if (oneOfRule) {
|
|
116
|
-
if (!dev) {
|
|
117
|
-
// replace nextjs picky style rules with simple minicssextract
|
|
118
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
119
|
-
oneOfRule.oneOf = [
|
|
120
|
-
{
|
|
121
|
-
test: /\.css$/i,
|
|
122
|
-
use: [MiniCssExtractPlugin.loader, 'css-loader'],
|
|
123
|
-
sideEffects: true,
|
|
124
|
-
},
|
|
125
|
-
]
|
|
126
|
-
const idx = webpackConfig.plugins.findIndex(
|
|
127
|
-
(x) => x.constructor.name === 'NextMiniCssExtractPlugin'
|
|
128
|
-
)
|
|
129
|
-
webpackConfig.plugins.splice(
|
|
130
|
-
idx,
|
|
131
|
-
1,
|
|
132
|
-
new MiniCssExtractPlugin({
|
|
133
|
-
filename: 'static/css/[name].[contenthash].css',
|
|
134
|
-
ignoreOrder: true,
|
|
135
|
-
})
|
|
136
|
-
)
|
|
137
|
-
} else {
|
|
138
|
-
const {
|
|
139
|
-
getGlobalCssLoader,
|
|
140
|
-
} = require('next/dist/build/webpack/config/blocks/css/loaders')
|
|
141
|
-
oneOfRule.oneOf.unshift({
|
|
142
|
-
test: /\.css$/i,
|
|
143
|
-
sideEffects: true,
|
|
144
|
-
use: getGlobalCssLoader(
|
|
145
|
-
{
|
|
146
|
-
assetPrefix: options.config.assetPrefix,
|
|
147
|
-
future: { webpack5: true },
|
|
148
|
-
isClient: !isServer,
|
|
149
|
-
isServer,
|
|
150
|
-
isDevelopment: true,
|
|
151
|
-
},
|
|
152
|
-
[],
|
|
153
|
-
[]
|
|
154
|
-
),
|
|
155
|
-
})
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// add loader
|
|
160
|
-
const shouldExclude = (x) => {
|
|
161
|
-
// analyze everything in our src dir
|
|
162
|
-
// analyze everything in the components dirs
|
|
163
|
-
const shouldInclude =
|
|
164
|
-
x.includes(options.dir) ||
|
|
165
|
-
tamaguiOptions.components.some(
|
|
166
|
-
(c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/dist/jsx/`)
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
return !shouldInclude
|
|
170
|
-
}
|
|
171
|
-
const [first, second, ...rest] = webpackConfig.module.rules
|
|
172
|
-
webpackConfig.module.rules = [
|
|
173
|
-
first,
|
|
174
|
-
second,
|
|
175
|
-
{
|
|
176
|
-
test: /\.(tsx|js|mjs|jsx)$/,
|
|
177
|
-
exclude: shouldExclude,
|
|
178
|
-
use: [
|
|
179
|
-
{
|
|
180
|
-
loader: 'esbuild-loader',
|
|
181
|
-
options: {
|
|
182
|
-
loader: 'tsx',
|
|
183
|
-
minify: false,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
loader: 'tamagui-loader',
|
|
188
|
-
options: tamaguiOptions,
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
...rest,
|
|
193
|
-
]
|
|
194
|
-
|
|
195
|
-
if (typeof nextConfig.webpack === 'function') {
|
|
196
|
-
return nextConfig.webpack(webpackConfig, options)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return webpackConfig
|
|
200
|
-
},
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
|
-
}
|