@tamagui/next-plugin 1.0.0-alpha.7 → 1.0.0-beta.0
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 +18 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/withTamagui.js +274 -0
- 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/esm/withTamagui.js +236 -0
- package/dist/esm/withTamagui.js.map +7 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/withTamagui.js +235 -0
- package/package.json +26 -17
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
- package/types/withTamagui.d.ts +10 -0
- package/types/withTamagui.d.ts.map +1 -0
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -197
- package/dist/index.cjs.map +0 -7
- package/dist/withTamagui.js +0 -155
- package/dist/withTamagui.js.map +0 -7
- package/src/index.ts +0 -1
- package/src/withTamagui.ts +0 -206
- package/types.d.ts +0 -19
|
@@ -0,0 +1,235 @@
|
|
|
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 MiniCSSExtractPlugin from "mini-css-extract-plugin";
|
|
7
|
+
import { lazyPostCSS } from "next/dist/build/webpack/config/blocks/css";
|
|
8
|
+
import { getGlobalCssLoader } from "next/dist/build/webpack/config/blocks/css/loaders";
|
|
9
|
+
import { shouldExclude } from "tamagui-loader";
|
|
10
|
+
import webpack from "webpack";
|
|
11
|
+
const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
12
|
+
return (nextConfig = {}) => {
|
|
13
|
+
return {
|
|
14
|
+
...nextConfig,
|
|
15
|
+
webpack: (webpackConfig, options) => {
|
|
16
|
+
var _a;
|
|
17
|
+
const { dir, config, dev, isServer } = options;
|
|
18
|
+
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
19
|
+
globalThis["__DEV__"] = dev;
|
|
20
|
+
}
|
|
21
|
+
const isNext12 = typeof ((_a = options.config) == null ? void 0 : _a.swcMinify) === "boolean";
|
|
22
|
+
const prefix = `${isServer ? " ssr " : " web "} |`;
|
|
23
|
+
const safeResolves = /* @__PURE__ */ __name((...resolves) => {
|
|
24
|
+
let res = [];
|
|
25
|
+
for (const [out, mod, replace] of resolves) {
|
|
26
|
+
try {
|
|
27
|
+
const next = [out, require.resolve(mod)];
|
|
28
|
+
if (replace) {
|
|
29
|
+
next[1] = next[1].replace(...replace);
|
|
30
|
+
}
|
|
31
|
+
res.push(next);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.log(prefix, `withTamagui skipping resolving ${out}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return Object.fromEntries(res);
|
|
37
|
+
}, "safeResolves");
|
|
38
|
+
const alias = {
|
|
39
|
+
...webpackConfig.resolve.alias || {},
|
|
40
|
+
...safeResolves(["react/jsx-runtime.js", "react/jsx-runtime"], ["react/jsx-runtime", "react/jsx-runtime"], ["react/jsx-dev-runtime.js", "react/jsx-dev-runtime"], ["react/jsx-dev-runtime", "react/jsx-dev-runtime"], ["react-native$", "react-native-web"], ["react-native-reanimated", "react-native-reanimated"], ["react-native-web$", "react-native-web"], ["@testing-library/react-native", "@tamagui/proxy-worm"], ["@gorhom/bottom-sheet$", "@gorhom/bottom-sheet", ["commonjs", "module"]]),
|
|
41
|
+
"react-native-web/src": require.resolve("react-native-web/dist")
|
|
42
|
+
};
|
|
43
|
+
webpackConfig.resolve.alias = alias;
|
|
44
|
+
webpackConfig.plugins.push(new webpack.DefinePlugin({
|
|
45
|
+
"process.env.IS_STATIC": '""',
|
|
46
|
+
"process.env.TAMAGUI_TARGET": '"web"',
|
|
47
|
+
__DEV__: JSON.stringify(dev)
|
|
48
|
+
}));
|
|
49
|
+
const excludeExports = tamaguiOptions.excludeReactNativeWebExports;
|
|
50
|
+
if (Array.isArray(excludeExports)) {
|
|
51
|
+
try {
|
|
52
|
+
const regexStr = `/react-native-web/.*(${excludeExports.join("|")}).*/`;
|
|
53
|
+
const regex = new RegExp(regexStr);
|
|
54
|
+
console.log(prefix, "exclude", regexStr);
|
|
55
|
+
webpackConfig.plugins.push(new webpack.NormalModuleReplacementPlugin(regex, require.resolve("@tamagui/proxy-worm")));
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.warn(`Invalid names provided to excludeReactNativeWebExports: ${excludeExports.join(", ")}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (process.env.IGNORE_TS_CONFIG_PATHS) {
|
|
61
|
+
if (process.env.DEBUG) {
|
|
62
|
+
console.log(prefix, "ignoring tsconfig paths");
|
|
63
|
+
}
|
|
64
|
+
if (webpackConfig.resolve.plugins[0]) {
|
|
65
|
+
delete webpackConfig.resolve.plugins[0].paths["@tamagui/*"];
|
|
66
|
+
delete webpackConfig.resolve.plugins[0].paths["tamagui"];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!dev) {
|
|
70
|
+
const cssMin = webpackConfig.optimization.minimizer.find((x) => x.toString().includes("css-minimizer-plugin"));
|
|
71
|
+
if (cssMin) {
|
|
72
|
+
webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(cssMin.index, 1);
|
|
73
|
+
}
|
|
74
|
+
webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin());
|
|
75
|
+
}
|
|
76
|
+
if (!webpackConfig.resolve.extensions.includes(".web.js")) {
|
|
77
|
+
webpackConfig.resolve.extensions = [".web.js", ...webpackConfig.resolve.extensions];
|
|
78
|
+
}
|
|
79
|
+
webpackConfig.resolve.mainFields.unshift("module:jsx");
|
|
80
|
+
if (isServer) {
|
|
81
|
+
const includeModule = /* @__PURE__ */ __name((context, request) => {
|
|
82
|
+
var _a2;
|
|
83
|
+
const fullPath = request[0] === "." ? path.join(context, request) : request;
|
|
84
|
+
const userRes = (_a2 = tamaguiOptions.shouldIncludeModuleServer) == null ? void 0 : _a2.call(tamaguiOptions, {
|
|
85
|
+
context,
|
|
86
|
+
request,
|
|
87
|
+
fullPath
|
|
88
|
+
});
|
|
89
|
+
if (userRes !== void 0) {
|
|
90
|
+
return userRes;
|
|
91
|
+
}
|
|
92
|
+
if (fullPath.startsWith("react-native-web") || fullPath.includes("node_modules/react-native-web") || /^(react-dom|react)\/$/.test(fullPath)) {
|
|
93
|
+
return `commonjs ${fullPath}`;
|
|
94
|
+
}
|
|
95
|
+
if (fullPath.includes("/moti/") || fullPath.includes("/solito/") || fullPath === "tamagui" || fullPath.startsWith("@tamagui/") || fullPath === "react-native-safe-area-context" || fullPath.startsWith("@react-navigation") || fullPath === "@gorhom/bottom-sheet") {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (/^\@?react-native-/.test(request)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}, "includeModule");
|
|
103
|
+
webpackConfig.externals = [
|
|
104
|
+
...webpackConfig.externals.map((external) => {
|
|
105
|
+
if (typeof external !== "function") {
|
|
106
|
+
return external;
|
|
107
|
+
}
|
|
108
|
+
return (ctx, cb) => {
|
|
109
|
+
const isCb = typeof cb === "function";
|
|
110
|
+
const res = includeModule(ctx.context, ctx.request);
|
|
111
|
+
if (isCb) {
|
|
112
|
+
if (typeof res === "string") {
|
|
113
|
+
return cb(null, res);
|
|
114
|
+
}
|
|
115
|
+
if (res) {
|
|
116
|
+
return external(ctx, cb);
|
|
117
|
+
}
|
|
118
|
+
return cb();
|
|
119
|
+
}
|
|
120
|
+
return !res ? Promise.resolve(void 0) : typeof res === "string" ? Promise.resolve(res) : external(ctx);
|
|
121
|
+
};
|
|
122
|
+
})
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf);
|
|
126
|
+
const cssLoader = getGlobalCssLoader({
|
|
127
|
+
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
128
|
+
future: nextConfig.future,
|
|
129
|
+
experimental: nextConfig.experimental || {},
|
|
130
|
+
isClient: !isServer,
|
|
131
|
+
isServer,
|
|
132
|
+
isDevelopment: dev
|
|
133
|
+
}, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), []);
|
|
134
|
+
if (oneOfRule) {
|
|
135
|
+
if (!dev) {
|
|
136
|
+
const postCSSLoader = cssLoader[cssLoader.length - 1];
|
|
137
|
+
oneOfRule.oneOf.unshift({
|
|
138
|
+
test: /\.css$/i,
|
|
139
|
+
use: [MiniCSSExtractPlugin.loader, "css-loader", postCSSLoader],
|
|
140
|
+
sideEffects: true
|
|
141
|
+
});
|
|
142
|
+
webpackConfig.plugins.push(new MiniCSSExtractPlugin({
|
|
143
|
+
filename: "static/css/[name].[contenthash].css",
|
|
144
|
+
ignoreOrder: true,
|
|
145
|
+
runtime: false
|
|
146
|
+
}));
|
|
147
|
+
} else {
|
|
148
|
+
oneOfRule.oneOf.unshift({
|
|
149
|
+
test: /\.css$/i,
|
|
150
|
+
sideEffects: true,
|
|
151
|
+
use: cssLoader
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (isNext12) {
|
|
156
|
+
const firstOneOfRule = webpackConfig.module.rules.findIndex((x) => x && !!x.oneOf);
|
|
157
|
+
const oneOfJSRules = webpackConfig.module.rules[firstOneOfRule].oneOf;
|
|
158
|
+
const afterSWCLoaderIndex = oneOfJSRules.findIndex((x) => x && x.use && x.use.loader === "next-swc-loader" && x.issuerLayer !== "api") + 1;
|
|
159
|
+
const swcLoader = oneOfJSRules[afterSWCLoaderIndex];
|
|
160
|
+
oneOfJSRules.splice(afterSWCLoaderIndex, 0, {
|
|
161
|
+
test: /(bottom-sheet).*\.[tj]sx?$/,
|
|
162
|
+
use: [
|
|
163
|
+
{
|
|
164
|
+
loader: "babel-loader",
|
|
165
|
+
options: {
|
|
166
|
+
plugins: [
|
|
167
|
+
"react-native-reanimated/plugin",
|
|
168
|
+
"@babel/plugin-transform-react-jsx"
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}, {
|
|
174
|
+
test: /\.(jsx?|tsx?)$/,
|
|
175
|
+
exclude: (path2) => shouldExclude(path2, options.dir, tamaguiOptions),
|
|
176
|
+
use: [
|
|
177
|
+
...[].concat(swcLoader.use),
|
|
178
|
+
{
|
|
179
|
+
loader: "tamagui-loader",
|
|
180
|
+
options: tamaguiOptions
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
const [first, second, ...rest] = webpackConfig.module.rules;
|
|
186
|
+
webpackConfig.module.rules = [
|
|
187
|
+
first,
|
|
188
|
+
second,
|
|
189
|
+
{
|
|
190
|
+
test: /\.(tsx|jsx)$/,
|
|
191
|
+
exclude: (path2) => shouldExclude(path2, options.dir, tamaguiOptions),
|
|
192
|
+
use: [
|
|
193
|
+
"thread-loader",
|
|
194
|
+
{
|
|
195
|
+
loader: "esbuild-loader",
|
|
196
|
+
options: {
|
|
197
|
+
loader: "tsx",
|
|
198
|
+
minify: false
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
loader: "tamagui-loader",
|
|
203
|
+
options: {
|
|
204
|
+
prefixLogs: prefix,
|
|
205
|
+
...tamaguiOptions
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
...rest
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
if (typeof nextConfig.webpack === "function") {
|
|
214
|
+
return nextConfig.webpack(webpackConfig, options);
|
|
215
|
+
}
|
|
216
|
+
return webpackConfig;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
}, "withTamagui");
|
|
221
|
+
function getSupportedBrowsers(dir, isDevelopment) {
|
|
222
|
+
let browsers;
|
|
223
|
+
try {
|
|
224
|
+
browsers = browserslist.loadConfig({
|
|
225
|
+
path: dir,
|
|
226
|
+
env: isDevelopment ? "development" : "production"
|
|
227
|
+
});
|
|
228
|
+
} catch {
|
|
229
|
+
}
|
|
230
|
+
return browsers;
|
|
231
|
+
}
|
|
232
|
+
__name(getSupportedBrowsers, "getSupportedBrowsers");
|
|
233
|
+
export {
|
|
234
|
+
withTamagui
|
|
235
|
+
};
|
package/package.json
CHANGED
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/next-plugin",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
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
|
-
"watch": "tamagui-build --watch"
|
|
16
|
+
"watch": "tamagui-build --watch",
|
|
17
|
+
"clean": "tamagui-build clean",
|
|
18
|
+
"clean:build": "tamagui-build clean:build"
|
|
16
19
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"@tamagui/
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@tamagui/proxy-worm": "^1.0.0-beta.0",
|
|
22
|
+
"@tamagui/static": "^1.0.0-beta.0",
|
|
23
|
+
"babel-loader": "^8.2.5",
|
|
24
|
+
"browserslist": "^4.19.1",
|
|
25
|
+
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
26
|
+
"esbuild-loader": "^2.18.0",
|
|
23
27
|
"next-compose-plugins": "^2.2.1",
|
|
24
|
-
"tamagui-loader": "^1.0.0-
|
|
28
|
+
"tamagui-loader": "^1.0.0-beta.0",
|
|
29
|
+
"thread-loader": "^3.0.4"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@tamagui/build": "^1.0.0-beta.0",
|
|
33
|
+
"next": "^12.1.5"
|
|
25
34
|
},
|
|
26
35
|
"peerDependencies": {
|
|
27
|
-
"next": ">=
|
|
36
|
+
"next": ">=12.0.0"
|
|
28
37
|
},
|
|
29
38
|
"publishConfig": {
|
|
30
39
|
"access": "public"
|
|
31
40
|
},
|
|
32
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
|
|
33
42
|
}
|
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,10 @@
|
|
|
1
|
+
import type { TamaguiOptions } from '@tamagui/static';
|
|
2
|
+
export declare type WithTamaguiProps = TamaguiOptions & {
|
|
3
|
+
shouldIncludeModuleServer?: (props: {
|
|
4
|
+
context: string;
|
|
5
|
+
request: string;
|
|
6
|
+
fullPath: string;
|
|
7
|
+
}) => boolean | string | undefined;
|
|
8
|
+
};
|
|
9
|
+
export declare const withTamagui: (tamaguiOptions: WithTamaguiProps) => (nextConfig?: any) => any;
|
|
10
|
+
//# sourceMappingURL=withTamagui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTamagui.d.ts","sourceRoot":"","sources":["../src/withTamagui.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AASrD,oBAAY,gBAAgB,GAAG,cAAc,GAAG;IAC9C,yBAAyB,CAAC,EAAE,CAAC,KAAK,EAAE;QAClC,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;KACjB,KAAK,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,WAAW,mBAAoB,gBAAgB,mBACtC,GAAG,QA6SxB,CAAA"}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Nate Wienert
|
|
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
|
-
SOFTWARE.
|
package/dist/index.cjs
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
26
|
-
var __export = (target, all) => {
|
|
27
|
-
__markAsModule(target);
|
|
28
|
-
for (var name in all)
|
|
29
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
30
|
-
};
|
|
31
|
-
var __reExport = (target, module2, desc) => {
|
|
32
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
33
|
-
for (let key of __getOwnPropNames(module2))
|
|
34
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
35
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
36
|
-
}
|
|
37
|
-
return target;
|
|
38
|
-
};
|
|
39
|
-
var __toModule = (module2) => {
|
|
40
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/index.ts
|
|
44
|
-
__export(exports, {
|
|
45
|
-
withTamagui: () => withTamagui
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// src/withTamagui.ts
|
|
49
|
-
var import_path = __toModule(require("path"));
|
|
50
|
-
var import_css_minimizer_webpack_plugin = __toModule(require("css-minimizer-webpack-plugin"));
|
|
51
|
-
var import_webpack = __toModule(require("webpack"));
|
|
52
|
-
var withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
53
|
-
return (nextConfig = {}) => {
|
|
54
|
-
return Object.assign({}, nextConfig, {
|
|
55
|
-
webpack: (webpackConfig, options) => {
|
|
56
|
-
const { config, dev, isServer } = options;
|
|
57
|
-
webpackConfig.resolve.alias = __spreadProps(__spreadValues({}, webpackConfig.resolve.alias || {}), {
|
|
58
|
-
"react-native$": "react-native-web",
|
|
59
|
-
"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
|
-
react: require.resolve("react"),
|
|
63
|
-
"react-dom": require.resolve("react-dom")
|
|
64
|
-
});
|
|
65
|
-
webpackConfig.plugins.push(new import_webpack.default.DefinePlugin({
|
|
66
|
-
"process.env.TAMAGUI_TARGET": '"web"'
|
|
67
|
-
}));
|
|
68
|
-
if (process.env.IGNORE_TS_CONFIG_PATHS) {
|
|
69
|
-
console.log("ignoring tsconfig paths, they mess up transpile");
|
|
70
|
-
delete webpackConfig.resolve.plugins[0].paths["@tamagui/*"];
|
|
71
|
-
delete webpackConfig.resolve.plugins[0].paths["tamagui"];
|
|
72
|
-
}
|
|
73
|
-
const cssMin = webpackConfig.optimization.minimizer.find((x) => x.toString().includes("css-minimizer-plugin"));
|
|
74
|
-
if (cssMin) {
|
|
75
|
-
webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(cssMin.index, 1);
|
|
76
|
-
}
|
|
77
|
-
webpackConfig.optimization.minimizer.push(new import_css_minimizer_webpack_plugin.default());
|
|
78
|
-
if (!webpackConfig.resolve.extensions.includes(".web.js")) {
|
|
79
|
-
webpackConfig.resolve.extensions = [".web.js", ...webpackConfig.resolve.extensions];
|
|
80
|
-
}
|
|
81
|
-
webpackConfig.resolve.mainFields.unshift("module:jsx");
|
|
82
|
-
const isWebpack5 = !!config.future.webpack5 || typeof config.webpack5 === "undefined";
|
|
83
|
-
const includeModule = /* @__PURE__ */ __name((context, request) => {
|
|
84
|
-
const fullPath = request[0] === "." ? import_path.default.join(context, request) : request;
|
|
85
|
-
if (/^\@?react-native-/.test(request)) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
if (fullPath.startsWith("react-native-web") || fullPath.includes("node_modules/react-native-web")) {
|
|
89
|
-
return `commonjs ${fullPath}`;
|
|
90
|
-
}
|
|
91
|
-
if (/^(react-dom|react)$/.test(fullPath)) {
|
|
92
|
-
return `commonjs ${fullPath}`;
|
|
93
|
-
}
|
|
94
|
-
return true;
|
|
95
|
-
}, "includeModule");
|
|
96
|
-
if (isServer) {
|
|
97
|
-
webpackConfig.externals = [
|
|
98
|
-
...webpackConfig.externals.map((external) => {
|
|
99
|
-
if (typeof external !== "function") {
|
|
100
|
-
return external;
|
|
101
|
-
}
|
|
102
|
-
if (isWebpack5) {
|
|
103
|
-
return (ctx, cb) => {
|
|
104
|
-
const res = includeModule(ctx.context, ctx.request);
|
|
105
|
-
if (typeof res === "string") {
|
|
106
|
-
return cb(null, res);
|
|
107
|
-
}
|
|
108
|
-
if (res) {
|
|
109
|
-
return external(ctx, cb);
|
|
110
|
-
}
|
|
111
|
-
return cb();
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
return (ctx, req, cb) => {
|
|
115
|
-
const res = includeModule(ctx, req);
|
|
116
|
-
if (typeof res === "string") {
|
|
117
|
-
return cb(null, res);
|
|
118
|
-
}
|
|
119
|
-
if (res) {
|
|
120
|
-
return external(ctx, cb);
|
|
121
|
-
}
|
|
122
|
-
return cb();
|
|
123
|
-
};
|
|
124
|
-
})
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf);
|
|
128
|
-
if (oneOfRule) {
|
|
129
|
-
if (!dev) {
|
|
130
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
131
|
-
oneOfRule.oneOf = [
|
|
132
|
-
{
|
|
133
|
-
test: /\.css$/i,
|
|
134
|
-
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
135
|
-
sideEffects: true
|
|
136
|
-
}
|
|
137
|
-
];
|
|
138
|
-
const idx = webpackConfig.plugins.findIndex((x) => x.constructor.name === "NextMiniCssExtractPlugin");
|
|
139
|
-
webpackConfig.plugins.splice(idx, 1, new MiniCssExtractPlugin({
|
|
140
|
-
filename: "static/css/[name].[contenthash].css",
|
|
141
|
-
ignoreOrder: true
|
|
142
|
-
}));
|
|
143
|
-
} else {
|
|
144
|
-
const {
|
|
145
|
-
getGlobalCssLoader
|
|
146
|
-
} = require("next/dist/build/webpack/config/blocks/css/loaders");
|
|
147
|
-
oneOfRule.oneOf.unshift({
|
|
148
|
-
test: /\.css$/i,
|
|
149
|
-
sideEffects: true,
|
|
150
|
-
use: getGlobalCssLoader({
|
|
151
|
-
assetPrefix: options.config.assetPrefix,
|
|
152
|
-
future: { webpack5: true },
|
|
153
|
-
isClient: !isServer,
|
|
154
|
-
isServer,
|
|
155
|
-
isDevelopment: true
|
|
156
|
-
}, [], [])
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const shouldExclude = /* @__PURE__ */ __name((x) => {
|
|
161
|
-
if (x.includes(options.dir) || tamaguiOptions.components.some((c) => x.includes(`/node_modules/${c}`) || x.includes(`${c}/_jsx/`))) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
return true;
|
|
165
|
-
}, "shouldExclude");
|
|
166
|
-
const [first, second, ...rest] = webpackConfig.module.rules;
|
|
167
|
-
webpackConfig.module.rules = [
|
|
168
|
-
first,
|
|
169
|
-
second,
|
|
170
|
-
{
|
|
171
|
-
test: /\.(tsx|js|mjs|jsx)$/,
|
|
172
|
-
exclude: shouldExclude,
|
|
173
|
-
use: [
|
|
174
|
-
{
|
|
175
|
-
loader: "esbuild-loader",
|
|
176
|
-
options: {
|
|
177
|
-
loader: "tsx",
|
|
178
|
-
minify: false
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
loader: "tamagui-loader",
|
|
183
|
-
options: tamaguiOptions
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
},
|
|
187
|
-
...rest
|
|
188
|
-
];
|
|
189
|
-
if (typeof nextConfig.webpack === "function") {
|
|
190
|
-
return nextConfig.webpack(webpackConfig, options);
|
|
191
|
-
}
|
|
192
|
-
return webpackConfig;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
}, "withTamagui");
|
|
197
|
-
//# sourceMappingURL=index.cjs.map
|
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,aAAa;AAAA,UACvB,8BAA8B;AAAA;AAIlC,YAAI,QAAQ,IAAI,wBAAwB;AACtC,kBAAQ,IAAI;AACZ,iBAAO,cAAc,QAAQ,QAAQ,GAAG,MAAM;AAC9C,iBAAO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