@tamagui/next-plugin 1.0.0-alpha.5 → 1.0.0-alpha.53
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/cjs/index.js +22 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/{index.cjs → cjs/withTamagui.js} +116 -51
- package/dist/cjs/withTamagui.js.map +7 -0
- package/dist/{index.js → esm/index.js} +0 -0
- package/dist/{index.js.map → esm/index.js.map} +1 -1
- package/dist/{withTamagui.js → esm/withTamagui.js} +98 -35
- package/dist/esm/withTamagui.js.map +7 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/withTamagui.js +217 -0
- package/package.json +20 -15
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
- package/types/withTamagui.d.ts +3 -0
- package/types/withTamagui.d.ts.map +1 -0
- package/dist/index.cjs.map +0 -7
- package/dist/withTamagui.js.map +0 -7
- package/src/index.ts +0 -1
- package/src/withTamagui.ts +0 -206
- package/types.d.ts +0 -18
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
7
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(module2))
|
|
9
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
10
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
15
|
+
return (module2, temp) => {
|
|
16
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
17
|
+
};
|
|
18
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__reExport(src_exports, require("./withTamagui"));
|
|
21
|
+
module.exports = __toCommonJS(src_exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -24,46 +24,61 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
24
24
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
25
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
26
26
|
var __export = (target, all) => {
|
|
27
|
-
__markAsModule(target);
|
|
28
27
|
for (var name in all)
|
|
29
28
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
30
29
|
};
|
|
31
|
-
var __reExport = (target, module2, desc) => {
|
|
30
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
32
31
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
33
32
|
for (let key of __getOwnPropNames(module2))
|
|
34
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
33
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
35
34
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
36
35
|
}
|
|
37
36
|
return target;
|
|
38
37
|
};
|
|
39
|
-
var
|
|
40
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default",
|
|
38
|
+
var __toESM = (module2, isNodeMode) => {
|
|
39
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
41
40
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
42
|
+
return (module2, temp) => {
|
|
43
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
44
|
+
};
|
|
45
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
46
|
+
var withTamagui_exports = {};
|
|
47
|
+
__export(withTamagui_exports, {
|
|
45
48
|
withTamagui: () => withTamagui
|
|
46
49
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
50
|
+
var import_path = __toESM(require("path"));
|
|
51
|
+
var import_browserslist = __toESM(require("browserslist"));
|
|
52
|
+
var import_css_minimizer_webpack_plugin = __toESM(require("css-minimizer-webpack-plugin"));
|
|
53
|
+
var import_css = require("next/dist/build/webpack/config/blocks/css");
|
|
54
|
+
var import_loaders = require("next/dist/build/webpack/config/blocks/css/loaders");
|
|
55
|
+
var import_webpack = __toESM(require("webpack"));
|
|
56
|
+
const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
53
57
|
return (nextConfig = {}) => {
|
|
54
58
|
return Object.assign({}, nextConfig, {
|
|
55
59
|
webpack: (webpackConfig, options) => {
|
|
56
|
-
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const { dir, config, dev, isServer } = options;
|
|
62
|
+
const isNext12 = typeof ((_a = options.config) == null ? void 0 : _a.swcMinify) === "boolean";
|
|
63
|
+
const jsxRuntime = require.resolve("react/jsx-runtime.js");
|
|
64
|
+
const jsxDevRuntime = require.resolve("react/jsx-dev-runtime.js");
|
|
65
|
+
const rnw = require.resolve("react-native-web");
|
|
66
|
+
const reanimated = require.resolve("react-native-reanimated");
|
|
57
67
|
webpackConfig.resolve.alias = __spreadProps(__spreadValues({}, webpackConfig.resolve.alias || {}), {
|
|
58
|
-
"react-
|
|
68
|
+
"react/jsx-runtime.js": jsxRuntime,
|
|
69
|
+
"react/jsx-runtime": jsxRuntime,
|
|
70
|
+
"react/jsx-dev-runtime.js": jsxDevRuntime,
|
|
71
|
+
"react/jsx-dev-runtime": jsxDevRuntime,
|
|
72
|
+
"react-native$": rnw,
|
|
73
|
+
"react-native-reanimated": reanimated,
|
|
74
|
+
"@gorhom/bottom-sheet$": require.resolve("@gorhom/bottom-sheet").replace("commonjs", "module"),
|
|
59
75
|
"react-native-web/src/modules/normalizeColor": require.resolve("react-native-web/dist/cjs/modules/normalizeColor"),
|
|
60
|
-
"react/jsx-runtime": require.resolve("react/jsx-runtime"),
|
|
61
|
-
"react/jsx-dev-runtime": require.resolve("react/jsx-dev-runtime"),
|
|
62
76
|
react: require.resolve("react"),
|
|
63
77
|
"react-dom": require.resolve("react-dom")
|
|
64
78
|
});
|
|
65
79
|
webpackConfig.plugins.push(new import_webpack.default.DefinePlugin({
|
|
66
|
-
"process.env.TAMAGUI_TARGET": '"web"'
|
|
80
|
+
"process.env.TAMAGUI_TARGET": '"web"',
|
|
81
|
+
__DEV__: JSON.stringify(dev)
|
|
67
82
|
}));
|
|
68
83
|
if (process.env.IGNORE_TS_CONFIG_PATHS) {
|
|
69
84
|
console.log("ignoring tsconfig paths, they mess up transpile");
|
|
@@ -79,12 +94,15 @@ var withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
79
94
|
webpackConfig.resolve.extensions = [".web.js", ...webpackConfig.resolve.extensions];
|
|
80
95
|
}
|
|
81
96
|
webpackConfig.resolve.mainFields.unshift("module:jsx");
|
|
82
|
-
const isWebpack5 = !!config.future.webpack5 || typeof config.webpack5 === "undefined";
|
|
97
|
+
const isWebpack5 = !!((_b = config.future) == null ? void 0 : _b.webpack5) || typeof config.webpack5 === "undefined";
|
|
83
98
|
const includeModule = /* @__PURE__ */ __name((context, request) => {
|
|
84
99
|
const fullPath = request[0] === "." ? import_path.default.join(context, request) : request;
|
|
85
100
|
if (/^\@?react-native-/.test(request)) {
|
|
86
101
|
return false;
|
|
87
102
|
}
|
|
103
|
+
if (fullPath === "@gorhom/bottom-sheet") {
|
|
104
|
+
return "inline";
|
|
105
|
+
}
|
|
88
106
|
if (fullPath.startsWith("react-native-web") || fullPath.includes("node_modules/react-native-web")) {
|
|
89
107
|
return `commonjs ${fullPath}`;
|
|
90
108
|
}
|
|
@@ -102,6 +120,9 @@ var withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
102
120
|
if (isWebpack5) {
|
|
103
121
|
return (ctx, cb) => {
|
|
104
122
|
const res = includeModule(ctx.context, ctx.request);
|
|
123
|
+
if (res === "inline") {
|
|
124
|
+
return cb();
|
|
125
|
+
}
|
|
105
126
|
if (typeof res === "string") {
|
|
106
127
|
return cb(null, res);
|
|
107
128
|
}
|
|
@@ -128,64 +149,95 @@ var withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
128
149
|
if (oneOfRule) {
|
|
129
150
|
if (!dev) {
|
|
130
151
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
131
|
-
oneOfRule.oneOf
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
];
|
|
152
|
+
oneOfRule.oneOf.unshift({
|
|
153
|
+
test: /\.css$/i,
|
|
154
|
+
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
155
|
+
sideEffects: true
|
|
156
|
+
});
|
|
138
157
|
const idx = webpackConfig.plugins.findIndex((x) => x.constructor.name === "NextMiniCssExtractPlugin");
|
|
139
158
|
webpackConfig.plugins.splice(idx, 1, new MiniCssExtractPlugin({
|
|
140
159
|
filename: "static/css/[name].[contenthash].css",
|
|
141
160
|
ignoreOrder: true
|
|
142
161
|
}));
|
|
143
162
|
} else {
|
|
144
|
-
const {
|
|
145
|
-
getGlobalCssLoader
|
|
146
|
-
} = require("next/dist/build/webpack/config/blocks/css/loaders");
|
|
147
163
|
oneOfRule.oneOf.unshift({
|
|
148
164
|
test: /\.css$/i,
|
|
149
165
|
sideEffects: true,
|
|
150
|
-
use: getGlobalCssLoader({
|
|
151
|
-
assetPrefix: options.config.assetPrefix,
|
|
152
|
-
future:
|
|
166
|
+
use: (0, import_loaders.getGlobalCssLoader)({
|
|
167
|
+
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
168
|
+
future: nextConfig.future,
|
|
169
|
+
experimental: nextConfig.experimental || {},
|
|
153
170
|
isClient: !isServer,
|
|
154
171
|
isServer,
|
|
155
172
|
isDevelopment: true
|
|
156
|
-
},
|
|
173
|
+
}, () => (0, import_css.lazyPostCSS)(dir, getSupportedBrowsers(dir, dev)), [])
|
|
157
174
|
});
|
|
158
175
|
}
|
|
159
176
|
}
|
|
160
177
|
const shouldExclude = /* @__PURE__ */ __name((x) => {
|
|
161
|
-
if (x.includes(
|
|
178
|
+
if (x.includes("react-native-reanimated")) {
|
|
162
179
|
return false;
|
|
163
180
|
}
|
|
164
|
-
|
|
181
|
+
const shouldInclude = x.includes(options.dir) || tamaguiOptions.components.some((c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/dist/jsx/`));
|
|
182
|
+
if (!shouldInclude) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
165
186
|
}, "shouldExclude");
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
{
|
|
171
|
-
test:
|
|
172
|
-
exclude: shouldExclude,
|
|
187
|
+
if (isNext12) {
|
|
188
|
+
const oneOfJSRules = webpackConfig.module.rules[2].oneOf;
|
|
189
|
+
const swcLoaderIndex = 3;
|
|
190
|
+
const swcLoader = oneOfJSRules[swcLoaderIndex];
|
|
191
|
+
oneOfJSRules.splice(swcLoaderIndex, 0, {
|
|
192
|
+
test: /(bottom-sheet).*\.[tj]sx?$/,
|
|
173
193
|
use: [
|
|
174
194
|
{
|
|
175
|
-
loader: "
|
|
195
|
+
loader: "babel-loader",
|
|
176
196
|
options: {
|
|
177
|
-
|
|
178
|
-
|
|
197
|
+
plugins: [
|
|
198
|
+
"react-native-reanimated/plugin",
|
|
199
|
+
"@babel/plugin-transform-react-jsx"
|
|
200
|
+
]
|
|
179
201
|
}
|
|
180
|
-
}
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
}, {
|
|
205
|
+
test: /\.(jsx?|tsx?)$/,
|
|
206
|
+
exclude: shouldExclude,
|
|
207
|
+
use: [
|
|
208
|
+
...[].concat(swcLoader.use),
|
|
181
209
|
{
|
|
182
210
|
loader: "tamagui-loader",
|
|
183
211
|
options: tamaguiOptions
|
|
184
212
|
}
|
|
185
213
|
]
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
214
|
+
});
|
|
215
|
+
} else {
|
|
216
|
+
const [first, second, ...rest] = webpackConfig.module.rules;
|
|
217
|
+
webpackConfig.module.rules = [
|
|
218
|
+
first,
|
|
219
|
+
second,
|
|
220
|
+
{
|
|
221
|
+
test: /\.(tsx|jsx)$/,
|
|
222
|
+
exclude: shouldExclude,
|
|
223
|
+
use: [
|
|
224
|
+
"thread-loader",
|
|
225
|
+
{
|
|
226
|
+
loader: "esbuild-loader",
|
|
227
|
+
options: {
|
|
228
|
+
loader: "tsx",
|
|
229
|
+
minify: false
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
loader: "tamagui-loader",
|
|
234
|
+
options: tamaguiOptions
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
...rest
|
|
239
|
+
];
|
|
240
|
+
}
|
|
189
241
|
if (typeof nextConfig.webpack === "function") {
|
|
190
242
|
return nextConfig.webpack(webpackConfig, options);
|
|
191
243
|
}
|
|
@@ -194,4 +246,17 @@ var withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
194
246
|
});
|
|
195
247
|
};
|
|
196
248
|
}, "withTamagui");
|
|
197
|
-
|
|
249
|
+
function getSupportedBrowsers(dir, isDevelopment) {
|
|
250
|
+
let browsers;
|
|
251
|
+
try {
|
|
252
|
+
browsers = import_browserslist.default.loadConfig({
|
|
253
|
+
path: dir,
|
|
254
|
+
env: isDevelopment ? "development" : "production"
|
|
255
|
+
});
|
|
256
|
+
} catch {
|
|
257
|
+
}
|
|
258
|
+
return browsers;
|
|
259
|
+
}
|
|
260
|
+
__name(getSupportedBrowsers, "getSupportedBrowsers");
|
|
261
|
+
module.exports = __toCommonJS(withTamagui_exports);
|
|
262
|
+
//# sourceMappingURL=withTamagui.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/withTamagui.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path'\n\nimport { TamaguiOptions } from '@tamagui/static'\nimport browserslist from 'browserslist'\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin'\nimport { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css'\nimport { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/loaders'\nimport webpack from 'webpack'\n\nexport const withTamagui = (tamaguiOptions: TamaguiOptions) => {\n return (nextConfig: any = {}) => {\n return Object.assign({}, nextConfig, {\n webpack: (webpackConfig: any, options) => {\n const { dir, config, dev, isServer } = options\n\n const isNext12 = typeof options.config?.swcMinify === 'boolean'\n\n // fixes https://github.com/kentcdodds/mdx-bundler/issues/143\n const jsxRuntime = require.resolve('react/jsx-runtime.js')\n const jsxDevRuntime = require.resolve('react/jsx-dev-runtime.js')\n const rnw = require.resolve('react-native-web')\n const reanimated = require.resolve('react-native-reanimated')\n\n webpackConfig.resolve.alias = {\n ...(webpackConfig.resolve.alias || {}),\n 'react/jsx-runtime.js': jsxRuntime,\n 'react/jsx-runtime': jsxRuntime,\n 'react/jsx-dev-runtime.js': jsxDevRuntime,\n 'react/jsx-dev-runtime': jsxDevRuntime,\n 'react-native$': rnw,\n 'react-native-reanimated': reanimated,\n '@gorhom/bottom-sheet$': require\n .resolve('@gorhom/bottom-sheet')\n .replace('commonjs', 'module'),\n 'react-native-web/src/modules/normalizeColor': require.resolve(\n 'react-native-web/dist/cjs/modules/normalizeColor'\n ),\n react: require.resolve('react'),\n 'react-dom': require.resolve('react-dom'),\n }\n\n webpackConfig.plugins.push(\n new webpack.DefinePlugin({\n 'process.env.TAMAGUI_TARGET': '\"web\"',\n __DEV__: JSON.stringify(dev),\n })\n )\n\n if (process.env.IGNORE_TS_CONFIG_PATHS) {\n console.log('ignoring tsconfig paths, they mess up transpile')\n delete webpackConfig.resolve.plugins[0].paths['@tamagui/*']\n delete webpackConfig.resolve.plugins[0].paths['tamagui']\n }\n\n // TODO document and make configurable\n // replace minifier with css-minimizer-webpack-plugin which handles deduping atomic styles\n const cssMin = webpackConfig.optimization.minimizer.find((x) =>\n x.toString().includes('css-minimizer-plugin')\n )\n if (cssMin) {\n webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(\n cssMin.index,\n 1\n )\n }\n webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin())\n\n if (!webpackConfig.resolve.extensions.includes('.web.js')) {\n webpackConfig.resolve.extensions = ['.web.js', ...webpackConfig.resolve.extensions]\n }\n\n // look for compiled js with jsx intact as specified by module:jsx\n webpackConfig.resolve.mainFields.unshift('module:jsx')\n\n const isWebpack5 = !!config.future?.webpack5 || typeof config.webpack5 === 'undefined'\n\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n if (/^\\@?react-native-/.test(request)) {\n return false\n }\n if (fullPath === '@gorhom/bottom-sheet') {\n return 'inline'\n }\n if (\n fullPath.startsWith('react-native-web') ||\n fullPath.includes('node_modules/react-native-web')\n ) {\n return `commonjs ${fullPath}`\n }\n if (/^(react-dom|react)$/.test(fullPath)) {\n return `commonjs ${fullPath}`\n }\n return true\n }\n\n if (isServer) {\n // externalize react native things from bundle\n webpackConfig.externals = [\n ...webpackConfig.externals.map((external) => {\n if (typeof external !== 'function') {\n return external\n }\n // only runs on server\n if (isWebpack5) {\n return (ctx, cb) => {\n const res = includeModule(ctx.context, ctx.request)\n if (res === 'inline') {\n return cb()\n }\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }\n return (ctx, req, cb) => {\n const res = includeModule(ctx, req)\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }),\n ]\n }\n\n const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf)\n\n if (oneOfRule) {\n if (!dev) {\n // replace nextjs picky style rules with simple minicssextract\n const MiniCssExtractPlugin = require('mini-css-extract-plugin')\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n use: [MiniCssExtractPlugin.loader, 'css-loader'],\n sideEffects: true,\n })\n const idx = webpackConfig.plugins.findIndex(\n (x) => x.constructor.name === 'NextMiniCssExtractPlugin'\n )\n webpackConfig.plugins.splice(\n idx,\n 1,\n new MiniCssExtractPlugin({\n filename: 'static/css/[name].[contenthash].css',\n ignoreOrder: true,\n })\n )\n } else {\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n sideEffects: true,\n use: getGlobalCssLoader(\n // @ts-ignore\n {\n assetPrefix: options.config.assetPrefix || config.assetPrefix,\n future: nextConfig.future,\n experimental: nextConfig.experimental || {},\n isClient: !isServer,\n isServer,\n isDevelopment: true,\n },\n // @ts-ignore\n () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)),\n []\n ),\n })\n }\n }\n\n // add loader\n const shouldExclude = (x: string) => {\n if (x.includes('react-native-reanimated')) {\n return false\n }\n // analyze everything in our jsx dir\n // analyze everything in the components dirs\n const shouldInclude =\n x.includes(options.dir) ||\n tamaguiOptions.components.some(\n (c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/dist/jsx/`)\n )\n if (!shouldInclude) {\n return true\n }\n return false\n }\n\n if (isNext12) {\n const oneOfJSRules: any[] = webpackConfig.module.rules[2].oneOf\n const swcLoaderIndex = 3\n const swcLoader = oneOfJSRules[swcLoaderIndex]\n // put an earlier loader where we just do tamagui stuff before regular swc\n oneOfJSRules.splice(\n swcLoaderIndex,\n 0,\n {\n test: /(bottom-sheet).*\\.[tj]sx?$/,\n use: [\n {\n loader: 'babel-loader',\n options: {\n plugins: [\n 'react-native-reanimated/plugin',\n '@babel/plugin-transform-react-jsx',\n ],\n },\n },\n ],\n },\n {\n test: /\\.(jsx?|tsx?)$/,\n exclude: shouldExclude,\n use: [\n ...[].concat(swcLoader.use),\n {\n loader: 'tamagui-loader',\n options: tamaguiOptions,\n },\n ],\n }\n )\n } else {\n // next 11 modify loader\n const [first, second, ...rest] = webpackConfig.module.rules\n webpackConfig.module.rules = [\n first,\n second,\n {\n test: /\\.(tsx|jsx)$/,\n exclude: shouldExclude,\n use: [\n 'thread-loader',\n {\n loader: 'esbuild-loader',\n options: {\n loader: 'tsx',\n minify: false,\n },\n },\n {\n loader: 'tamagui-loader',\n options: tamaguiOptions,\n },\n ],\n },\n ...rest,\n ]\n }\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(webpackConfig, options)\n }\n\n return webpackConfig\n },\n })\n }\n}\n\nfunction getSupportedBrowsers(dir, isDevelopment) {\n let browsers\n try {\n browsers = browserslist.loadConfig({\n path: dir,\n env: isDevelopment ? 'development' : 'production',\n })\n } catch {}\n\n return browsers\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,0BAAyB;AACzB,0CAA+B;AAC/B,iBAA4B;AAC5B,qBAAmC;AACnC,qBAAoB;AAEb,MAAM,cAAc,wBAAC,mBAAmC;AAC7D,SAAO,CAAC,aAAkB,OAAO;AAC/B,WAAO,OAAO,OAAO,IAAI,YAAY;AAAA,MACnC,SAAS,CAAC,eAAoB,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,OAAO;AACtD,wBAAc,OAAO,QAAQ;AAAA,YAC3B;AAAA,YACA;AAAA,YACA;AAAA,cACE,MAAM;AAAA,cACN,SAAS;AAAA,cACT,KAAK;AAAA,gBACH;AAAA,gBACA;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA,oBACP,QAAQ;AAAA,oBACR,QAAQ;AAAA;AAAA;AAAA,gBAGZ;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA;AAAA;AAAA;AAAA,YAIf,GAAG;AAAA;AAAA;AAIP,YAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAO,WAAW,QAAQ,eAAe;AAAA;AAG3C,eAAO;AAAA;AAAA;AAAA;AAAA,GA5PY;AAkQ3B,8BAA8B,KAAK,eAAe;AAChD,MAAI;AACJ,MAAI;AACF,eAAW,4BAAa,WAAW;AAAA,MACjC,MAAM;AAAA,MACN,KAAK,gBAAgB,gBAAgB;AAAA;AAAA,UAEvC;AAAA;AAEF,SAAO;AAAA;AATA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import path from "path";
|
|
4
|
+
import browserslist from "browserslist";
|
|
4
5
|
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
6
|
+
import { lazyPostCSS } from "next/dist/build/webpack/config/blocks/css";
|
|
7
|
+
import { getGlobalCssLoader } from "next/dist/build/webpack/config/blocks/css/loaders";
|
|
5
8
|
import webpack from "webpack";
|
|
6
9
|
const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
7
10
|
return (nextConfig = {}) => {
|
|
8
11
|
return Object.assign({}, nextConfig, {
|
|
9
12
|
webpack: (webpackConfig, options) => {
|
|
10
|
-
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { dir, config, dev, isServer } = options;
|
|
15
|
+
const isNext12 = typeof ((_a = options.config) == null ? void 0 : _a.swcMinify) === "boolean";
|
|
16
|
+
const jsxRuntime = require.resolve("react/jsx-runtime.js");
|
|
17
|
+
const jsxDevRuntime = require.resolve("react/jsx-dev-runtime.js");
|
|
18
|
+
const rnw = require.resolve("react-native-web");
|
|
19
|
+
const reanimated = require.resolve("react-native-reanimated");
|
|
11
20
|
webpackConfig.resolve.alias = {
|
|
12
21
|
...webpackConfig.resolve.alias || {},
|
|
13
|
-
"react-
|
|
22
|
+
"react/jsx-runtime.js": jsxRuntime,
|
|
23
|
+
"react/jsx-runtime": jsxRuntime,
|
|
24
|
+
"react/jsx-dev-runtime.js": jsxDevRuntime,
|
|
25
|
+
"react/jsx-dev-runtime": jsxDevRuntime,
|
|
26
|
+
"react-native$": rnw,
|
|
27
|
+
"react-native-reanimated": reanimated,
|
|
28
|
+
"@gorhom/bottom-sheet$": require.resolve("@gorhom/bottom-sheet").replace("commonjs", "module"),
|
|
14
29
|
"react-native-web/src/modules/normalizeColor": require.resolve("react-native-web/dist/cjs/modules/normalizeColor"),
|
|
15
|
-
"react/jsx-runtime": require.resolve("react/jsx-runtime"),
|
|
16
|
-
"react/jsx-dev-runtime": require.resolve("react/jsx-dev-runtime"),
|
|
17
30
|
react: require.resolve("react"),
|
|
18
31
|
"react-dom": require.resolve("react-dom")
|
|
19
32
|
};
|
|
20
33
|
webpackConfig.plugins.push(new webpack.DefinePlugin({
|
|
21
|
-
"process.env.TAMAGUI_TARGET": '"web"'
|
|
34
|
+
"process.env.TAMAGUI_TARGET": '"web"',
|
|
35
|
+
__DEV__: JSON.stringify(dev)
|
|
22
36
|
}));
|
|
23
37
|
if (process.env.IGNORE_TS_CONFIG_PATHS) {
|
|
24
38
|
console.log("ignoring tsconfig paths, they mess up transpile");
|
|
@@ -34,12 +48,15 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
34
48
|
webpackConfig.resolve.extensions = [".web.js", ...webpackConfig.resolve.extensions];
|
|
35
49
|
}
|
|
36
50
|
webpackConfig.resolve.mainFields.unshift("module:jsx");
|
|
37
|
-
const isWebpack5 = !!config.future.webpack5 || typeof config.webpack5 === "undefined";
|
|
51
|
+
const isWebpack5 = !!((_b = config.future) == null ? void 0 : _b.webpack5) || typeof config.webpack5 === "undefined";
|
|
38
52
|
const includeModule = /* @__PURE__ */ __name((context, request) => {
|
|
39
53
|
const fullPath = request[0] === "." ? path.join(context, request) : request;
|
|
40
54
|
if (/^\@?react-native-/.test(request)) {
|
|
41
55
|
return false;
|
|
42
56
|
}
|
|
57
|
+
if (fullPath === "@gorhom/bottom-sheet") {
|
|
58
|
+
return "inline";
|
|
59
|
+
}
|
|
43
60
|
if (fullPath.startsWith("react-native-web") || fullPath.includes("node_modules/react-native-web")) {
|
|
44
61
|
return `commonjs ${fullPath}`;
|
|
45
62
|
}
|
|
@@ -57,6 +74,9 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
57
74
|
if (isWebpack5) {
|
|
58
75
|
return (ctx, cb) => {
|
|
59
76
|
const res = includeModule(ctx.context, ctx.request);
|
|
77
|
+
if (res === "inline") {
|
|
78
|
+
return cb();
|
|
79
|
+
}
|
|
60
80
|
if (typeof res === "string") {
|
|
61
81
|
return cb(null, res);
|
|
62
82
|
}
|
|
@@ -83,64 +103,95 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
83
103
|
if (oneOfRule) {
|
|
84
104
|
if (!dev) {
|
|
85
105
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
86
|
-
oneOfRule.oneOf
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
];
|
|
106
|
+
oneOfRule.oneOf.unshift({
|
|
107
|
+
test: /\.css$/i,
|
|
108
|
+
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
109
|
+
sideEffects: true
|
|
110
|
+
});
|
|
93
111
|
const idx = webpackConfig.plugins.findIndex((x) => x.constructor.name === "NextMiniCssExtractPlugin");
|
|
94
112
|
webpackConfig.plugins.splice(idx, 1, new MiniCssExtractPlugin({
|
|
95
113
|
filename: "static/css/[name].[contenthash].css",
|
|
96
114
|
ignoreOrder: true
|
|
97
115
|
}));
|
|
98
116
|
} else {
|
|
99
|
-
const {
|
|
100
|
-
getGlobalCssLoader
|
|
101
|
-
} = require("next/dist/build/webpack/config/blocks/css/loaders");
|
|
102
117
|
oneOfRule.oneOf.unshift({
|
|
103
118
|
test: /\.css$/i,
|
|
104
119
|
sideEffects: true,
|
|
105
120
|
use: getGlobalCssLoader({
|
|
106
|
-
assetPrefix: options.config.assetPrefix,
|
|
107
|
-
future:
|
|
121
|
+
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
122
|
+
future: nextConfig.future,
|
|
123
|
+
experimental: nextConfig.experimental || {},
|
|
108
124
|
isClient: !isServer,
|
|
109
125
|
isServer,
|
|
110
126
|
isDevelopment: true
|
|
111
|
-
},
|
|
127
|
+
}, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
|
|
112
128
|
});
|
|
113
129
|
}
|
|
114
130
|
}
|
|
115
131
|
const shouldExclude = /* @__PURE__ */ __name((x) => {
|
|
116
|
-
if (x.includes(
|
|
132
|
+
if (x.includes("react-native-reanimated")) {
|
|
117
133
|
return false;
|
|
118
134
|
}
|
|
119
|
-
|
|
135
|
+
const shouldInclude = x.includes(options.dir) || tamaguiOptions.components.some((c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/dist/jsx/`));
|
|
136
|
+
if (!shouldInclude) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
120
140
|
}, "shouldExclude");
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{
|
|
126
|
-
test:
|
|
127
|
-
exclude: shouldExclude,
|
|
141
|
+
if (isNext12) {
|
|
142
|
+
const oneOfJSRules = webpackConfig.module.rules[2].oneOf;
|
|
143
|
+
const swcLoaderIndex = 3;
|
|
144
|
+
const swcLoader = oneOfJSRules[swcLoaderIndex];
|
|
145
|
+
oneOfJSRules.splice(swcLoaderIndex, 0, {
|
|
146
|
+
test: /(bottom-sheet).*\.[tj]sx?$/,
|
|
128
147
|
use: [
|
|
129
148
|
{
|
|
130
|
-
loader: "
|
|
149
|
+
loader: "babel-loader",
|
|
131
150
|
options: {
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
plugins: [
|
|
152
|
+
"react-native-reanimated/plugin",
|
|
153
|
+
"@babel/plugin-transform-react-jsx"
|
|
154
|
+
]
|
|
134
155
|
}
|
|
135
|
-
}
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}, {
|
|
159
|
+
test: /\.(jsx?|tsx?)$/,
|
|
160
|
+
exclude: shouldExclude,
|
|
161
|
+
use: [
|
|
162
|
+
...[].concat(swcLoader.use),
|
|
136
163
|
{
|
|
137
164
|
loader: "tamagui-loader",
|
|
138
165
|
options: tamaguiOptions
|
|
139
166
|
}
|
|
140
167
|
]
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
const [first, second, ...rest] = webpackConfig.module.rules;
|
|
171
|
+
webpackConfig.module.rules = [
|
|
172
|
+
first,
|
|
173
|
+
second,
|
|
174
|
+
{
|
|
175
|
+
test: /\.(tsx|jsx)$/,
|
|
176
|
+
exclude: shouldExclude,
|
|
177
|
+
use: [
|
|
178
|
+
"thread-loader",
|
|
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
|
+
}
|
|
144
195
|
if (typeof nextConfig.webpack === "function") {
|
|
145
196
|
return nextConfig.webpack(webpackConfig, options);
|
|
146
197
|
}
|
|
@@ -149,6 +200,18 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
149
200
|
});
|
|
150
201
|
};
|
|
151
202
|
}, "withTamagui");
|
|
203
|
+
function getSupportedBrowsers(dir, isDevelopment) {
|
|
204
|
+
let browsers;
|
|
205
|
+
try {
|
|
206
|
+
browsers = browserslist.loadConfig({
|
|
207
|
+
path: dir,
|
|
208
|
+
env: isDevelopment ? "development" : "production"
|
|
209
|
+
});
|
|
210
|
+
} catch {
|
|
211
|
+
}
|
|
212
|
+
return browsers;
|
|
213
|
+
}
|
|
214
|
+
__name(getSupportedBrowsers, "getSupportedBrowsers");
|
|
152
215
|
export {
|
|
153
216
|
withTamagui
|
|
154
217
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/withTamagui.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path'\n\nimport { TamaguiOptions } from '@tamagui/static'\nimport browserslist from 'browserslist'\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin'\nimport { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css'\nimport { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/loaders'\nimport webpack from 'webpack'\n\nexport const withTamagui = (tamaguiOptions: TamaguiOptions) => {\n return (nextConfig: any = {}) => {\n return Object.assign({}, nextConfig, {\n webpack: (webpackConfig: any, options) => {\n const { dir, config, dev, isServer } = options\n\n const isNext12 = typeof options.config?.swcMinify === 'boolean'\n\n // fixes https://github.com/kentcdodds/mdx-bundler/issues/143\n const jsxRuntime = require.resolve('react/jsx-runtime.js')\n const jsxDevRuntime = require.resolve('react/jsx-dev-runtime.js')\n const rnw = require.resolve('react-native-web')\n const reanimated = require.resolve('react-native-reanimated')\n\n webpackConfig.resolve.alias = {\n ...(webpackConfig.resolve.alias || {}),\n 'react/jsx-runtime.js': jsxRuntime,\n 'react/jsx-runtime': jsxRuntime,\n 'react/jsx-dev-runtime.js': jsxDevRuntime,\n 'react/jsx-dev-runtime': jsxDevRuntime,\n 'react-native$': rnw,\n 'react-native-reanimated': reanimated,\n '@gorhom/bottom-sheet$': require\n .resolve('@gorhom/bottom-sheet')\n .replace('commonjs', 'module'),\n 'react-native-web/src/modules/normalizeColor': require.resolve(\n 'react-native-web/dist/cjs/modules/normalizeColor'\n ),\n react: require.resolve('react'),\n 'react-dom': require.resolve('react-dom'),\n }\n\n webpackConfig.plugins.push(\n new webpack.DefinePlugin({\n 'process.env.TAMAGUI_TARGET': '\"web\"',\n __DEV__: JSON.stringify(dev),\n })\n )\n\n if (process.env.IGNORE_TS_CONFIG_PATHS) {\n console.log('ignoring tsconfig paths, they mess up transpile')\n delete webpackConfig.resolve.plugins[0].paths['@tamagui/*']\n delete webpackConfig.resolve.plugins[0].paths['tamagui']\n }\n\n // TODO document and make configurable\n // replace minifier with css-minimizer-webpack-plugin which handles deduping atomic styles\n const cssMin = webpackConfig.optimization.minimizer.find((x) =>\n x.toString().includes('css-minimizer-plugin')\n )\n if (cssMin) {\n webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(\n cssMin.index,\n 1\n )\n }\n webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin())\n\n if (!webpackConfig.resolve.extensions.includes('.web.js')) {\n webpackConfig.resolve.extensions = ['.web.js', ...webpackConfig.resolve.extensions]\n }\n\n // look for compiled js with jsx intact as specified by module:jsx\n webpackConfig.resolve.mainFields.unshift('module:jsx')\n\n const isWebpack5 = !!config.future?.webpack5 || typeof config.webpack5 === 'undefined'\n\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n if (/^\\@?react-native-/.test(request)) {\n return false\n }\n if (fullPath === '@gorhom/bottom-sheet') {\n return 'inline'\n }\n if (\n fullPath.startsWith('react-native-web') ||\n fullPath.includes('node_modules/react-native-web')\n ) {\n return `commonjs ${fullPath}`\n }\n if (/^(react-dom|react)$/.test(fullPath)) {\n return `commonjs ${fullPath}`\n }\n return true\n }\n\n if (isServer) {\n // externalize react native things from bundle\n webpackConfig.externals = [\n ...webpackConfig.externals.map((external) => {\n if (typeof external !== 'function') {\n return external\n }\n // only runs on server\n if (isWebpack5) {\n return (ctx, cb) => {\n const res = includeModule(ctx.context, ctx.request)\n if (res === 'inline') {\n return cb()\n }\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }\n return (ctx, req, cb) => {\n const res = includeModule(ctx, req)\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }),\n ]\n }\n\n const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf)\n\n if (oneOfRule) {\n if (!dev) {\n // replace nextjs picky style rules with simple minicssextract\n const MiniCssExtractPlugin = require('mini-css-extract-plugin')\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n use: [MiniCssExtractPlugin.loader, 'css-loader'],\n sideEffects: true,\n })\n const idx = webpackConfig.plugins.findIndex(\n (x) => x.constructor.name === 'NextMiniCssExtractPlugin'\n )\n webpackConfig.plugins.splice(\n idx,\n 1,\n new MiniCssExtractPlugin({\n filename: 'static/css/[name].[contenthash].css',\n ignoreOrder: true,\n })\n )\n } else {\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n sideEffects: true,\n use: getGlobalCssLoader(\n // @ts-ignore\n {\n assetPrefix: options.config.assetPrefix || config.assetPrefix,\n future: nextConfig.future,\n experimental: nextConfig.experimental || {},\n isClient: !isServer,\n isServer,\n isDevelopment: true,\n },\n // @ts-ignore\n () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)),\n []\n ),\n })\n }\n }\n\n // add loader\n const shouldExclude = (x: string) => {\n if (x.includes('react-native-reanimated')) {\n return false\n }\n // analyze everything in our jsx dir\n // analyze everything in the components dirs\n const shouldInclude =\n x.includes(options.dir) ||\n tamaguiOptions.components.some(\n (c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/dist/jsx/`)\n )\n if (!shouldInclude) {\n return true\n }\n return false\n }\n\n if (isNext12) {\n const oneOfJSRules: any[] = webpackConfig.module.rules[2].oneOf\n const swcLoaderIndex = 3\n const swcLoader = oneOfJSRules[swcLoaderIndex]\n // put an earlier loader where we just do tamagui stuff before regular swc\n oneOfJSRules.splice(\n swcLoaderIndex,\n 0,\n {\n test: /(bottom-sheet).*\\.[tj]sx?$/,\n use: [\n {\n loader: 'babel-loader',\n options: {\n plugins: [\n 'react-native-reanimated/plugin',\n '@babel/plugin-transform-react-jsx',\n ],\n },\n },\n ],\n },\n {\n test: /\\.(jsx?|tsx?)$/,\n exclude: shouldExclude,\n use: [\n ...[].concat(swcLoader.use),\n {\n loader: 'tamagui-loader',\n options: tamaguiOptions,\n },\n ],\n }\n )\n } else {\n // next 11 modify loader\n const [first, second, ...rest] = webpackConfig.module.rules\n webpackConfig.module.rules = [\n first,\n second,\n {\n test: /\\.(tsx|jsx)$/,\n exclude: shouldExclude,\n use: [\n 'thread-loader',\n {\n loader: 'esbuild-loader',\n options: {\n loader: 'tsx',\n minify: false,\n },\n },\n {\n loader: 'tamagui-loader',\n options: tamaguiOptions,\n },\n ],\n },\n ...rest,\n ]\n }\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(webpackConfig, options)\n }\n\n return webpackConfig\n },\n })\n }\n}\n\nfunction getSupportedBrowsers(dir, isDevelopment) {\n let browsers\n try {\n browsers = browserslist.loadConfig({\n path: dir,\n env: isDevelopment ? 'development' : 'production',\n })\n } catch {}\n\n return browsers\n}\n"],
|
|
5
|
+
"mappings": ";;AAAA;AAGA;AACA;AACA;AACA;AACA;AAEO,MAAM,cAAc,wBAAC,mBAAmC;AAC7D,SAAO,CAAC,aAAkB,OAAO;AAC/B,WAAO,OAAO,OAAO,I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gBAAM,CAAC,OAAO,WAAW,QAAQ,cAAc,OAAO;AACtD,wBAAc,OAAO,QAAQ;AAAA,YAC3B;AAAA,YACA;AAAA,YACA;AAAA,cACE,MAAM;AAAA,cACN,SAAS;AAAA,cACT,KAAK;AAAA,gBACH;AAAA,gBACA;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA,oBACP,QAAQ;AAAA,oBACR,QAAQ;AAAA;AAAA;AAAA,gBAGZ;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA;AAAA;AAAA;AAAA,YAIf,GAAG;AAAA;AAAA;AAIP,YAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAO,WAAW,QAAQ,eAAe;AAAA;AAG3C,eAAO;AAAA;AAAA;AAAA;AAAA,GA5PY;AAkQ3B,8BAA8B,KAAK,eAAe;AAChD,MAAI;AACJ,MAAI;AACF,eAAW,aAAa,WAAW;AAAA,MACjC,MAAM;AAAA,MACN,KAAK,gBAAgB,gBAAgB;AAAA;AAAA,UAEvC;AAAA;AAEF,SAAO;AAAA;AATA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./withTamagui";
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import path from "path";
|
|
4
|
+
import browserslist from "browserslist";
|
|
5
|
+
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
6
|
+
import { lazyPostCSS } from "next/dist/build/webpack/config/blocks/css";
|
|
7
|
+
import { getGlobalCssLoader } from "next/dist/build/webpack/config/blocks/css/loaders";
|
|
8
|
+
import webpack from "webpack";
|
|
9
|
+
const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
10
|
+
return (nextConfig = {}) => {
|
|
11
|
+
return Object.assign({}, nextConfig, {
|
|
12
|
+
webpack: (webpackConfig, options) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { dir, config, dev, isServer } = options;
|
|
15
|
+
const isNext12 = typeof ((_a = options.config) == null ? void 0 : _a.swcMinify) === "boolean";
|
|
16
|
+
const jsxRuntime = require.resolve("react/jsx-runtime.js");
|
|
17
|
+
const jsxDevRuntime = require.resolve("react/jsx-dev-runtime.js");
|
|
18
|
+
const rnw = require.resolve("react-native-web");
|
|
19
|
+
const reanimated = require.resolve("react-native-reanimated");
|
|
20
|
+
webpackConfig.resolve.alias = {
|
|
21
|
+
...webpackConfig.resolve.alias || {},
|
|
22
|
+
"react/jsx-runtime.js": jsxRuntime,
|
|
23
|
+
"react/jsx-runtime": jsxRuntime,
|
|
24
|
+
"react/jsx-dev-runtime.js": jsxDevRuntime,
|
|
25
|
+
"react/jsx-dev-runtime": jsxDevRuntime,
|
|
26
|
+
"react-native$": rnw,
|
|
27
|
+
"react-native-reanimated": reanimated,
|
|
28
|
+
"@gorhom/bottom-sheet$": require.resolve("@gorhom/bottom-sheet").replace("commonjs", "module"),
|
|
29
|
+
"react-native-web/src/modules/normalizeColor": require.resolve("react-native-web/dist/cjs/modules/normalizeColor"),
|
|
30
|
+
react: require.resolve("react"),
|
|
31
|
+
"react-dom": require.resolve("react-dom")
|
|
32
|
+
};
|
|
33
|
+
webpackConfig.plugins.push(new webpack.DefinePlugin({
|
|
34
|
+
"process.env.TAMAGUI_TARGET": '"web"',
|
|
35
|
+
__DEV__: JSON.stringify(dev)
|
|
36
|
+
}));
|
|
37
|
+
if (process.env.IGNORE_TS_CONFIG_PATHS) {
|
|
38
|
+
console.log("ignoring tsconfig paths, they mess up transpile");
|
|
39
|
+
delete webpackConfig.resolve.plugins[0].paths["@tamagui/*"];
|
|
40
|
+
delete webpackConfig.resolve.plugins[0].paths["tamagui"];
|
|
41
|
+
}
|
|
42
|
+
const cssMin = webpackConfig.optimization.minimizer.find((x) => x.toString().includes("css-minimizer-plugin"));
|
|
43
|
+
if (cssMin) {
|
|
44
|
+
webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(cssMin.index, 1);
|
|
45
|
+
}
|
|
46
|
+
webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin());
|
|
47
|
+
if (!webpackConfig.resolve.extensions.includes(".web.js")) {
|
|
48
|
+
webpackConfig.resolve.extensions = [".web.js", ...webpackConfig.resolve.extensions];
|
|
49
|
+
}
|
|
50
|
+
webpackConfig.resolve.mainFields.unshift("module:jsx");
|
|
51
|
+
const isWebpack5 = !!((_b = config.future) == null ? void 0 : _b.webpack5) || typeof config.webpack5 === "undefined";
|
|
52
|
+
const includeModule = /* @__PURE__ */ __name((context, request) => {
|
|
53
|
+
const fullPath = request[0] === "." ? path.join(context, request) : request;
|
|
54
|
+
if (/^\@?react-native-/.test(request)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (fullPath === "@gorhom/bottom-sheet") {
|
|
58
|
+
return "inline";
|
|
59
|
+
}
|
|
60
|
+
if (fullPath.startsWith("react-native-web") || fullPath.includes("node_modules/react-native-web")) {
|
|
61
|
+
return `commonjs ${fullPath}`;
|
|
62
|
+
}
|
|
63
|
+
if (/^(react-dom|react)$/.test(fullPath)) {
|
|
64
|
+
return `commonjs ${fullPath}`;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}, "includeModule");
|
|
68
|
+
if (isServer) {
|
|
69
|
+
webpackConfig.externals = [
|
|
70
|
+
...webpackConfig.externals.map((external) => {
|
|
71
|
+
if (typeof external !== "function") {
|
|
72
|
+
return external;
|
|
73
|
+
}
|
|
74
|
+
if (isWebpack5) {
|
|
75
|
+
return (ctx, cb) => {
|
|
76
|
+
const res = includeModule(ctx.context, ctx.request);
|
|
77
|
+
if (res === "inline") {
|
|
78
|
+
return cb();
|
|
79
|
+
}
|
|
80
|
+
if (typeof res === "string") {
|
|
81
|
+
return cb(null, res);
|
|
82
|
+
}
|
|
83
|
+
if (res) {
|
|
84
|
+
return external(ctx, cb);
|
|
85
|
+
}
|
|
86
|
+
return cb();
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return (ctx, req, cb) => {
|
|
90
|
+
const res = includeModule(ctx, req);
|
|
91
|
+
if (typeof res === "string") {
|
|
92
|
+
return cb(null, res);
|
|
93
|
+
}
|
|
94
|
+
if (res) {
|
|
95
|
+
return external(ctx, cb);
|
|
96
|
+
}
|
|
97
|
+
return cb();
|
|
98
|
+
};
|
|
99
|
+
})
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf);
|
|
103
|
+
if (oneOfRule) {
|
|
104
|
+
if (!dev) {
|
|
105
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
106
|
+
oneOfRule.oneOf.unshift({
|
|
107
|
+
test: /\.css$/i,
|
|
108
|
+
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
109
|
+
sideEffects: true
|
|
110
|
+
});
|
|
111
|
+
const idx = webpackConfig.plugins.findIndex((x) => x.constructor.name === "NextMiniCssExtractPlugin");
|
|
112
|
+
webpackConfig.plugins.splice(idx, 1, new MiniCssExtractPlugin({
|
|
113
|
+
filename: "static/css/[name].[contenthash].css",
|
|
114
|
+
ignoreOrder: true
|
|
115
|
+
}));
|
|
116
|
+
} else {
|
|
117
|
+
oneOfRule.oneOf.unshift({
|
|
118
|
+
test: /\.css$/i,
|
|
119
|
+
sideEffects: true,
|
|
120
|
+
use: getGlobalCssLoader({
|
|
121
|
+
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
122
|
+
future: nextConfig.future,
|
|
123
|
+
experimental: nextConfig.experimental || {},
|
|
124
|
+
isClient: !isServer,
|
|
125
|
+
isServer,
|
|
126
|
+
isDevelopment: true
|
|
127
|
+
}, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const shouldExclude = /* @__PURE__ */ __name((x) => {
|
|
132
|
+
if (x.includes("react-native-reanimated")) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
const shouldInclude = x.includes(options.dir) || tamaguiOptions.components.some((c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/dist/jsx/`));
|
|
136
|
+
if (!shouldInclude) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}, "shouldExclude");
|
|
141
|
+
if (isNext12) {
|
|
142
|
+
const oneOfJSRules = webpackConfig.module.rules[2].oneOf;
|
|
143
|
+
const swcLoaderIndex = 3;
|
|
144
|
+
const swcLoader = oneOfJSRules[swcLoaderIndex];
|
|
145
|
+
oneOfJSRules.splice(swcLoaderIndex, 0, {
|
|
146
|
+
test: /(bottom-sheet).*\.[tj]sx?$/,
|
|
147
|
+
use: [
|
|
148
|
+
{
|
|
149
|
+
loader: "babel-loader",
|
|
150
|
+
options: {
|
|
151
|
+
plugins: [
|
|
152
|
+
"react-native-reanimated/plugin",
|
|
153
|
+
"@babel/plugin-transform-react-jsx"
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}, {
|
|
159
|
+
test: /\.(jsx?|tsx?)$/,
|
|
160
|
+
exclude: shouldExclude,
|
|
161
|
+
use: [
|
|
162
|
+
...[].concat(swcLoader.use),
|
|
163
|
+
{
|
|
164
|
+
loader: "tamagui-loader",
|
|
165
|
+
options: tamaguiOptions
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
const [first, second, ...rest] = webpackConfig.module.rules;
|
|
171
|
+
webpackConfig.module.rules = [
|
|
172
|
+
first,
|
|
173
|
+
second,
|
|
174
|
+
{
|
|
175
|
+
test: /\.(tsx|jsx)$/,
|
|
176
|
+
exclude: shouldExclude,
|
|
177
|
+
use: [
|
|
178
|
+
"thread-loader",
|
|
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
|
+
return webpackConfig;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
}, "withTamagui");
|
|
203
|
+
function getSupportedBrowsers(dir, isDevelopment) {
|
|
204
|
+
let browsers;
|
|
205
|
+
try {
|
|
206
|
+
browsers = browserslist.loadConfig({
|
|
207
|
+
path: dir,
|
|
208
|
+
env: isDevelopment ? "development" : "production"
|
|
209
|
+
});
|
|
210
|
+
} catch {
|
|
211
|
+
}
|
|
212
|
+
return browsers;
|
|
213
|
+
}
|
|
214
|
+
__name(getSupportedBrowsers, "getSupportedBrowsers");
|
|
215
|
+
export {
|
|
216
|
+
withTamagui
|
|
217
|
+
};
|
package/package.json
CHANGED
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/next-plugin",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.53",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"typings": "types",
|
|
7
|
+
"main": "dist/cjs",
|
|
8
|
+
"module": "dist/esm",
|
|
9
|
+
"module:jsx": "dist/jsx",
|
|
8
10
|
"files": [
|
|
9
|
-
"types
|
|
10
|
-
"dist"
|
|
11
|
-
"src"
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
12
13
|
],
|
|
13
14
|
"scripts": {
|
|
14
15
|
"build": "tamagui-build",
|
|
15
16
|
"watch": "tamagui-build --watch"
|
|
16
17
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"@tamagui/static": "^1.0.0-alpha.5",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@tamagui/static": "^1.0.0-alpha.53",
|
|
20
|
+
"browserslist": "^4.19.1",
|
|
21
21
|
"css-minimizer-webpack-plugin": "^3.1.3",
|
|
22
|
-
"esbuild-loader": "^2.
|
|
22
|
+
"esbuild-loader": "^2.18.0",
|
|
23
23
|
"next-compose-plugins": "^2.2.1",
|
|
24
|
-
"tamagui-loader": "^1.0.0-alpha.
|
|
24
|
+
"tamagui-loader": "^1.0.0-alpha.53",
|
|
25
|
+
"thread-loader": "^3.0.4"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@tamagui/build": "^1.0.0-alpha.44",
|
|
29
|
+
"next": "^12.0.10"
|
|
25
30
|
},
|
|
26
31
|
"peerDependencies": {
|
|
27
|
-
"next": ">=
|
|
32
|
+
"next": ">=12.0.0"
|
|
28
33
|
},
|
|
29
34
|
"publishConfig": {
|
|
30
35
|
"access": "public"
|
|
31
36
|
},
|
|
32
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "7ccc9ca8d4a21041ea2bdc7e4586de07ddb21b35"
|
|
33
38
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTamagui.d.ts","sourceRoot":"","sources":["../src/withTamagui.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAOhD,eAAO,MAAM,WAAW,mBAAoB,cAAc,mBACpC,GAAG,QA+PxB,CAAA"}
|
package/dist/index.cjs.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/withTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './withTamagui'\n", "import path from 'path'\n\nimport { TamaguiOptions } from '@tamagui/static'\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin'\nimport webpack from 'webpack'\n\nexport const withTamagui = (tamaguiOptions: TamaguiOptions) => {\n return (nextConfig: any = {}) => {\n return Object.assign({}, nextConfig, {\n webpack: (webpackConfig, options) => {\n const { config, dev, isServer } = options\n\n webpackConfig.resolve.alias = {\n ...(webpackConfig.resolve.alias || {}),\n 'react-native$': 'react-native-web',\n 'react-native-web/src/modules/normalizeColor': require.resolve(\n 'react-native-web/dist/cjs/modules/normalizeColor'\n ),\n // fix mdx-bundler issue importing .js specifically\n // 'react/jsx-runtime.js': require.resolve('react/jsx-runtime'),\n 'react/jsx-runtime': require.resolve('react/jsx-runtime'),\n 'react/jsx-dev-runtime': require.resolve('react/jsx-dev-runtime'),\n react: require.resolve('react'),\n 'react-dom': require.resolve('react-dom'),\n }\n\n webpackConfig.plugins.push(\n new webpack.DefinePlugin({\n 'process.env.TAMAGUI_TARGET': '\"web\"',\n })\n )\n\n if (process.env.IGNORE_TS_CONFIG_PATHS) {\n console.log('ignoring tsconfig paths, they mess up transpile')\n delete webpackConfig.resolve.plugins[0].paths['@tamagui/*']\n delete webpackConfig.resolve.plugins[0].paths['tamagui']\n }\n\n // TODO document and make configurable\n // replace minifier with css-minimizer-webpack-plugin which handles deduping atomic styles\n const cssMin = webpackConfig.optimization.minimizer.find((x) =>\n x.toString().includes('css-minimizer-plugin')\n )\n if (cssMin) {\n webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(\n cssMin.index,\n 1\n )\n }\n webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin())\n\n if (!webpackConfig.resolve.extensions.includes('.web.js')) {\n webpackConfig.resolve.extensions = ['.web.js', ...webpackConfig.resolve.extensions]\n }\n\n // look for compiled js with jsx intact as specified by module:jsx\n webpackConfig.resolve.mainFields.unshift('module:jsx')\n\n // why is it undefined on next11??? but it says using webpack5\n const isWebpack5 = !!config.future.webpack5 || typeof config.webpack5 === 'undefined'\n\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n if (/^\\@?react-native-/.test(request)) {\n return false\n }\n if (\n fullPath.startsWith('react-native-web') ||\n fullPath.includes('node_modules/react-native-web')\n ) {\n return `commonjs ${fullPath}`\n }\n if (/^(react-dom|react)$/.test(fullPath)) {\n return `commonjs ${fullPath}`\n }\n return true\n }\n\n if (isServer) {\n // externalize react native things from bundle\n webpackConfig.externals = [\n ...webpackConfig.externals.map((external) => {\n if (typeof external !== 'function') {\n return external\n }\n // only runs on server\n if (isWebpack5) {\n return (ctx, cb) => {\n const res = includeModule(ctx.context, ctx.request)\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }\n return (ctx, req, cb) => {\n const res = includeModule(ctx, req)\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }),\n ]\n }\n\n const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf)\n\n if (oneOfRule) {\n if (!dev) {\n // replace nextjs picky style rules with simple minicssextract\n const MiniCssExtractPlugin = require('mini-css-extract-plugin')\n oneOfRule.oneOf = [\n {\n test: /\\.css$/i,\n use: [MiniCssExtractPlugin.loader, 'css-loader'],\n sideEffects: true,\n },\n ]\n const idx = webpackConfig.plugins.findIndex(\n (x) => x.constructor.name === 'NextMiniCssExtractPlugin'\n )\n webpackConfig.plugins.splice(\n idx,\n 1,\n new MiniCssExtractPlugin({\n filename: 'static/css/[name].[contenthash].css',\n ignoreOrder: true,\n })\n )\n } else {\n const {\n getGlobalCssLoader,\n } = require('next/dist/build/webpack/config/blocks/css/loaders')\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n sideEffects: true,\n use: getGlobalCssLoader(\n {\n assetPrefix: options.config.assetPrefix,\n future: { webpack5: true },\n isClient: !isServer,\n isServer,\n isDevelopment: true,\n },\n [],\n []\n ),\n })\n }\n }\n\n // add loader\n const shouldExclude = (x) => {\n // analyze everything in our src dir\n // analyze everything in the components dirs\n if (\n x.includes(options.dir) ||\n tamaguiOptions.components.some(\n (c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/_jsx/`)\n )\n ) {\n return false\n }\n // exclude everything else\n return true\n }\n const [first, second, ...rest] = webpackConfig.module.rules\n webpackConfig.module.rules = [\n first,\n second,\n {\n test: /\\.(tsx|js|mjs|jsx)$/,\n exclude: shouldExclude,\n use: [\n {\n loader: 'esbuild-loader',\n options: {\n loader: 'tsx',\n minify: false,\n },\n },\n {\n loader: 'tamagui-loader',\n options: tamaguiOptions,\n },\n ],\n },\n ...rest,\n ]\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(webpackConfig, options)\n }\n\n return webpackConfig\n },\n })\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;;;ACAA,kBAAiB;AAGjB,0CAA+B;AAC/B,qBAAoB;AAEb,IAAM,cAAc,wBAAC,mBAAmC;AAC7D,SAAO,CAAC,aAAkB,OAAO;AAC/B,WAAO,OAAO,OAAO,IAAI,YAAY;AAAA,MACnC,SAAS,CAAC,eAAe,YAAY;AACnC,cAAM,EAAE,QAAQ,KAAK,aAAa;AAElC,sBAAc,QAAQ,QAAQ,iCACxB,cAAc,QAAQ,SAAS,KADP;AAAA,UAE5B,iBAAiB;AAAA,UACjB,+CACE;AAAA,UAIF,qBAAqC;AAAA,UACrC,yBAAyC;AAAA,UACzC,OAAuB;AAAA,UACvB,aAA6B;AAAA;AAG/B,sBAAc,QAAQ,KACpB,IAAI,uBAAQ,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QAAQ,cAAc,OAAO;AACtD,sBAAc,OAAO,QAAQ;AAAA,UAC3B;AAAA,UACA;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,SAAS;AAAA,YACT,KAAK;AAAA,cACH;AAAA,gBACE,QAAQ;AAAA,gBACR,SAAS;AAAA,kBACP,QAAQ;AAAA,kBACR,QAAQ;AAAA;AAAA;AAAA,cAGZ;AAAA,gBACE,QAAQ;AAAA,gBACR,SAAS;AAAA;AAAA;AAAA;AAAA,UAIf,GAAG;AAAA;AAGL,YAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAO,WAAW,QAAQ,eAAe;AAAA;AAG3C,eAAO;AAAA;AAAA;AAAA;AAAA,GAnMY;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/withTamagui.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/withTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path'\n\nimport { TamaguiOptions } from '@tamagui/static'\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin'\nimport webpack from 'webpack'\n\nexport const withTamagui = (tamaguiOptions: TamaguiOptions) => {\n return (nextConfig: any = {}) => {\n return Object.assign({}, nextConfig, {\n webpack: (webpackConfig, options) => {\n const { config, dev, isServer } = options\n\n webpackConfig.resolve.alias = {\n ...(webpackConfig.resolve.alias || {}),\n 'react-native$': 'react-native-web',\n 'react-native-web/src/modules/normalizeColor': require.resolve(\n 'react-native-web/dist/cjs/modules/normalizeColor'\n ),\n // fix mdx-bundler issue importing .js specifically\n // 'react/jsx-runtime.js': require.resolve('react/jsx-runtime'),\n 'react/jsx-runtime': require.resolve('react/jsx-runtime'),\n 'react/jsx-dev-runtime': require.resolve('react/jsx-dev-runtime'),\n react: require.resolve('react'),\n 'react-dom': require.resolve('react-dom'),\n }\n\n webpackConfig.plugins.push(\n new webpack.DefinePlugin({\n 'process.env.TAMAGUI_TARGET': '\"web\"',\n })\n )\n\n if (process.env.IGNORE_TS_CONFIG_PATHS) {\n console.log('ignoring tsconfig paths, they mess up transpile')\n delete webpackConfig.resolve.plugins[0].paths['@tamagui/*']\n delete webpackConfig.resolve.plugins[0].paths['tamagui']\n }\n\n // TODO document and make configurable\n // replace minifier with css-minimizer-webpack-plugin which handles deduping atomic styles\n const cssMin = webpackConfig.optimization.minimizer.find((x) =>\n x.toString().includes('css-minimizer-plugin')\n )\n if (cssMin) {\n webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(\n cssMin.index,\n 1\n )\n }\n webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin())\n\n if (!webpackConfig.resolve.extensions.includes('.web.js')) {\n webpackConfig.resolve.extensions = ['.web.js', ...webpackConfig.resolve.extensions]\n }\n\n // look for compiled js with jsx intact as specified by module:jsx\n webpackConfig.resolve.mainFields.unshift('module:jsx')\n\n // why is it undefined on next11??? but it says using webpack5\n const isWebpack5 = !!config.future.webpack5 || typeof config.webpack5 === 'undefined'\n\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n if (/^\\@?react-native-/.test(request)) {\n return false\n }\n if (\n fullPath.startsWith('react-native-web') ||\n fullPath.includes('node_modules/react-native-web')\n ) {\n return `commonjs ${fullPath}`\n }\n if (/^(react-dom|react)$/.test(fullPath)) {\n return `commonjs ${fullPath}`\n }\n return true\n }\n\n if (isServer) {\n // externalize react native things from bundle\n webpackConfig.externals = [\n ...webpackConfig.externals.map((external) => {\n if (typeof external !== 'function') {\n return external\n }\n // only runs on server\n if (isWebpack5) {\n return (ctx, cb) => {\n const res = includeModule(ctx.context, ctx.request)\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }\n return (ctx, req, cb) => {\n const res = includeModule(ctx, req)\n if (typeof res === 'string') {\n return cb(null, res)\n }\n if (res) {\n return external(ctx, cb)\n }\n return cb()\n }\n }),\n ]\n }\n\n const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf)\n\n if (oneOfRule) {\n if (!dev) {\n // replace nextjs picky style rules with simple minicssextract\n const MiniCssExtractPlugin = require('mini-css-extract-plugin')\n oneOfRule.oneOf = [\n {\n test: /\\.css$/i,\n use: [MiniCssExtractPlugin.loader, 'css-loader'],\n sideEffects: true,\n },\n ]\n const idx = webpackConfig.plugins.findIndex(\n (x) => x.constructor.name === 'NextMiniCssExtractPlugin'\n )\n webpackConfig.plugins.splice(\n idx,\n 1,\n new MiniCssExtractPlugin({\n filename: 'static/css/[name].[contenthash].css',\n ignoreOrder: true,\n })\n )\n } else {\n const {\n getGlobalCssLoader,\n } = require('next/dist/build/webpack/config/blocks/css/loaders')\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n sideEffects: true,\n use: getGlobalCssLoader(\n {\n assetPrefix: options.config.assetPrefix,\n future: { webpack5: true },\n isClient: !isServer,\n isServer,\n isDevelopment: true,\n },\n [],\n []\n ),\n })\n }\n }\n\n // add loader\n const shouldExclude = (x) => {\n // analyze everything in our src dir\n // analyze everything in the components dirs\n if (\n x.includes(options.dir) ||\n tamaguiOptions.components.some(\n (c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/_jsx/`)\n )\n ) {\n return false\n }\n // exclude everything else\n return true\n }\n const [first, second, ...rest] = webpackConfig.module.rules\n webpackConfig.module.rules = [\n first,\n second,\n {\n test: /\\.(tsx|js|mjs|jsx)$/,\n exclude: shouldExclude,\n use: [\n {\n loader: 'esbuild-loader',\n options: {\n loader: 'tsx',\n minify: false,\n },\n },\n {\n loader: 'tamagui-loader',\n options: tamaguiOptions,\n },\n ],\n },\n ...rest,\n ]\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(webpackConfig, options)\n }\n\n return webpackConfig\n },\n })\n }\n}\n"],
|
|
5
|
-
"mappings": ";;AAAA;AAGA;AACA;AAEO,MAAM,cAAc,wBAAC,mBAAmC;AAC7D,SAAO,C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AAA,gBAC5B,QAAQ,EAAE,UAAU;AAAA,gBACpB,UAAU,CAAC;AAAA,gBACX;AAAA,gBACA,eAAe;AAAA,iBAEjB,IACA;AAAA;AAAA;AAAA;AAOR,cAAM,gBAAgB,wBAAC,MAAM;AAG3B,cACE,EAAE,SAAS,QAAQ,QACnB,eAAe,WAAW,KACxB,CAAC,MAAM,EAAE,SAAS,iBAAiB,QAAQ,EAAE,SAAS,GAAG,aAE3D;AACA,mBAAO;AAAA;AAGT,iBAAO;AAAA,WAZa;AActB,cAAM,CAAC,OAAO,WAAW,QAAQ,cAAc,OAAO;AACtD,sBAAc,OAAO,QAAQ;AAAA,UAC3B;AAAA,UACA;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,SAAS;AAAA,YACT,KAAK;AAAA,cACH;AAAA,gBACE,QAAQ;AAAA,gBACR,SAAS;AAAA,kBACP,QAAQ;AAAA,kBACR,QAAQ;AAAA;AAAA;AAAA,cAGZ;AAAA,gBACE,QAAQ;AAAA,gBACR,SAAS;AAAA;AAAA;AAAA;AAAA,UAIf,GAAG;AAAA;AAGL,YAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAO,WAAW,QAAQ,eAAe;AAAA;AAG3C,eAAO;AAAA;AAAA;AAAA;AAAA,GAnMY;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './withTamagui'
|
package/src/withTamagui.ts
DELETED
|
@@ -1,206 +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
|
-
if (
|
|
164
|
-
x.includes(options.dir) ||
|
|
165
|
-
tamaguiOptions.components.some(
|
|
166
|
-
(c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/_jsx/`)
|
|
167
|
-
)
|
|
168
|
-
) {
|
|
169
|
-
return false
|
|
170
|
-
}
|
|
171
|
-
// exclude everything else
|
|
172
|
-
return true
|
|
173
|
-
}
|
|
174
|
-
const [first, second, ...rest] = webpackConfig.module.rules
|
|
175
|
-
webpackConfig.module.rules = [
|
|
176
|
-
first,
|
|
177
|
-
second,
|
|
178
|
-
{
|
|
179
|
-
test: /\.(tsx|js|mjs|jsx)$/,
|
|
180
|
-
exclude: shouldExclude,
|
|
181
|
-
use: [
|
|
182
|
-
{
|
|
183
|
-
loader: 'esbuild-loader',
|
|
184
|
-
options: {
|
|
185
|
-
loader: 'tsx',
|
|
186
|
-
minify: false,
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
loader: 'tamagui-loader',
|
|
191
|
-
options: tamaguiOptions,
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
...rest,
|
|
196
|
-
]
|
|
197
|
-
|
|
198
|
-
if (typeof nextConfig.webpack === 'function') {
|
|
199
|
-
return nextConfig.webpack(webpackConfig, options)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return webpackConfig
|
|
203
|
-
},
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
}
|
package/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v5.9.0
|
|
2
|
-
|
|
3
|
-
export interface TamaguiOptions {
|
|
4
|
-
components: string[];
|
|
5
|
-
config?: string;
|
|
6
|
-
evaluateVars?: boolean;
|
|
7
|
-
importsWhitelist?: string[];
|
|
8
|
-
disableExtraction?: boolean;
|
|
9
|
-
exclude?: RegExp;
|
|
10
|
-
logTimings?: boolean;
|
|
11
|
-
cssPath?: string;
|
|
12
|
-
cssData?: any;
|
|
13
|
-
deoptProps?: Set<string>;
|
|
14
|
-
excludeProps?: string[];
|
|
15
|
-
}
|
|
16
|
-
export declare const withTamagui: (tamaguiOptions: TamaguiOptions) => (nextConfig?: any) => any;
|
|
17
|
-
|
|
18
|
-
export {};
|