@tamagui/next-plugin 1.88.13 → 1.89.0-1706308641099

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
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.
@@ -0,0 +1 @@
1
+ export * from "./withTamagui.mjs";
@@ -0,0 +1,123 @@
1
+ import path from "path";
2
+ import browserslist from "browserslist";
3
+ import { lazyPostCSS } from "next/dist/build/webpack/config/blocks/css";
4
+ import { getGlobalCssLoader } from "next/dist/build/webpack/config/blocks/css/loaders";
5
+ import { TamaguiPlugin } from "tamagui-loader";
6
+ import webpack from "webpack";
7
+ const withTamagui = tamaguiOptions => (nextConfig = {}) => {
8
+ const isAppDir = tamaguiOptions?.appDir || nextConfig.experimental?.appDir;
9
+ return {
10
+ ...nextConfig,
11
+ webpack: (webpackConfig, options) => {
12
+ const {
13
+ dir,
14
+ config,
15
+ dev,
16
+ isServer
17
+ } = options;
18
+ if (typeof globalThis.__DEV__ > "u" && (globalThis.__DEV__ = dev), !(typeof options.config?.swcMinify == "boolean")) throw new Error("Next.js 12 only supported");
19
+ const prefix = `${isServer ? " ssr " : " web "} |`,
20
+ SEP = path.sep;
21
+ process.env.ANALYZE === "true" && Object.assign(webpackConfig.optimization, {
22
+ concatenateModules: !1
23
+ });
24
+ const enableStudio = options.dev && options.nextRuntime === "nodejs" && isServer,
25
+ tamaguiPlugin = new TamaguiPlugin({
26
+ enableStudio,
27
+ isServer,
28
+ ...tamaguiOptions
29
+ }),
30
+ defines = {
31
+ "process.env.IS_STATIC": JSON.stringify(""),
32
+ "process.env.TAMAGUI_TARGET": '"web"',
33
+ "process.env.TAMAGUI_IS_SERVER": JSON.stringify(isServer ? "true" : ""),
34
+ __DEV__: JSON.stringify(dev),
35
+ ...((tamaguiOptions.outputCSS || process.env.TAMAGUI_DOES_SSR_CSS) && {
36
+ "process.env.TAMAGUI_DOES_SSR_CSS": JSON.stringify(process.env.TAMAGUI_DOES_SSR_CSS ?? (tamaguiOptions?.doesMutateThemes === !1 ? !0 : "mutates-themes"))
37
+ }),
38
+ // TODO move to TamaguiPlugin
39
+ // optimizes inserts automatically assuming CSS wont be "removed" on page change
40
+ ...(tamaguiOptions.emitSingleCSSFile && {
41
+ "process.env.TAMAGUI_INSERT_SELECTOR_TRIES": JSON.stringify("1")
42
+ })
43
+ };
44
+ if (webpackConfig.plugins.push(new webpack.DefinePlugin(defines)), process.env.IGNORE_TS_CONFIG_PATHS && (process.env.DEBUG && console.info(prefix, "ignoring tsconfig paths"), webpackConfig.resolve.plugins[0] && (delete webpackConfig.resolve.plugins[0].paths["@tamagui/*"], delete webpackConfig.resolve.plugins[0].paths.tamagui)), isServer || (nextConfig.modularizeImports ??= {}, nextConfig.modularizeImports["@tamagui/lucide-icons"] = {
45
+ transform: "@tamagui/lucide-icons/dist/esm/icons/{{kebabCase member}}",
46
+ skipDefaultConversion: !0
47
+ }), isServer) {
48
+ const externalize = (context, request) => {
49
+ const fullPath = request[0] === "." ? path.join(context, request) : request;
50
+ if (tamaguiOptions.shouldExcludeFromServer) {
51
+ const userRes = tamaguiOptions.shouldExcludeFromServer({
52
+ context,
53
+ request,
54
+ fullPath
55
+ });
56
+ if (userRes !== void 0) return userRes;
57
+ }
58
+ if (tamaguiPlugin.isInComponentModule(fullPath) || fullPath.includes("react-native-web") || fullPath === "react-native" || fullPath.startsWith(`react-native${SEP}`)) return !1;
59
+ if (
60
+ // feather icons uses react-native-svg which needs to be aliased
61
+ // fullPath.includes('/lucide-icons/') ||
62
+ fullPath.startsWith("react-native-web") || fullPath.includes(`node_modules${SEP}react-native-web`) || new RegExp(`^(react-dom|react)${SEP}$`).test(fullPath)) return `commonjs ${fullPath}`;
63
+ if (!(fullPath.startsWith("moti") || fullPath.startsWith("solito") || fullPath === "tamagui" || fullPath.startsWith("@tamagui") || fullPath === "react-native-safe-area-context" || fullPath === "expo-linear-gradient" || fullPath.startsWith("@react-navigation") || fullPath.startsWith("@gorhom"))) return !/^@?react-native-/.test(request);
64
+ };
65
+ webpackConfig.externals = [...webpackConfig.externals.map(external => typeof external != "function" ? external : (ctx, cb) => {
66
+ const isCb = typeof cb == "function",
67
+ res = externalize(ctx.context, ctx.request);
68
+ return isCb ? typeof res == "string" ? cb(null, res) : res ? external(ctx, cb) : cb() : res ? typeof res == "string" ? Promise.resolve(res) : external(ctx) : Promise.resolve(void 0);
69
+ })];
70
+ }
71
+ const cssRules = webpackConfig.module.rules.find(rule => Array.isArray(rule.oneOf) && rule.oneOf.some(({
72
+ test
73
+ }) => typeof test == "object" && typeof test.test == "function" && test.test("filename.css"))).oneOf;
74
+ if (cssRules) {
75
+ tamaguiOptions.enableLegacyFontSupport && cssRules.unshift({
76
+ test: /\.(woff(2)?|eot|ttf|otf)(\?v=\d+\.\d+\.\d+)?$/,
77
+ use: [{
78
+ loader: require.resolve("url-loader"),
79
+ options: {
80
+ limit: nextConfig.inlineFontLimit || 1024,
81
+ fallback: require.resolve("file-loader"),
82
+ publicPath: `${nextConfig.assetPrefix || ""}/_next/static/chunks/fonts/`,
83
+ outputPath: `${isServer ? "../" : ""}static/chunks/fonts/`,
84
+ name: "[name].[ext]"
85
+ }
86
+ }]
87
+ });
88
+ const cssLoader = getGlobalCssLoader(
89
+ // @ts-ignore
90
+ {
91
+ assetPrefix: nextConfig.assetPrefix || options.config.assetPrefix || config.assetPrefix,
92
+ future: nextConfig.future,
93
+ experimental: nextConfig.experimental || {},
94
+ isEdgeRuntime: !0,
95
+ isProduction: !dev,
96
+ targetWeb: !0,
97
+ isClient: !isServer,
98
+ isServer,
99
+ isDevelopment: dev
100
+ },
101
+ // @ts-ignore
102
+ () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), []);
103
+ isAppDir || cssRules.unshift({
104
+ test: tamaguiOptions.includeCSSTest ?? /\.tamagui\.css$/,
105
+ sideEffects: !0,
106
+ use: cssLoader
107
+ });
108
+ }
109
+ return webpackConfig.plugins.push(tamaguiPlugin), typeof nextConfig.webpack == "function" ? nextConfig.webpack(webpackConfig, options) : webpackConfig;
110
+ }
111
+ };
112
+ };
113
+ function getSupportedBrowsers(dir, isDevelopment) {
114
+ let browsers;
115
+ try {
116
+ browsers = browserslist.loadConfig({
117
+ path: dir,
118
+ env: isDevelopment ? "development" : "production"
119
+ });
120
+ } catch {}
121
+ return browsers;
122
+ }
123
+ export { withTamagui };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/next-plugin",
3
- "version": "1.88.13",
3
+ "version": "1.89.0-1706308641099",
4
4
  "source": "src/index.ts",
5
5
  "license": "MIT",
6
6
  "types": "./types/index.d.ts",
@@ -21,21 +21,21 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@babel/preset-react": "^7.23.3",
24
- "@tamagui/proxy-worm": "1.88.13",
25
- "@tamagui/react-native-svg": "1.88.13",
26
- "@tamagui/static": "1.88.13",
24
+ "@tamagui/proxy-worm": "1.89.0-1706308641099",
25
+ "@tamagui/react-native-svg": "1.89.0-1706308641099",
26
+ "@tamagui/static": "1.89.0-1706308641099",
27
27
  "babel-loader": "^9.1.2",
28
28
  "browserslist": "^4.22.2",
29
29
  "css-loader": "^6.7.4",
30
30
  "esbuild-loader": "^3.0.1",
31
31
  "file-loader": "^6.2.0",
32
32
  "html-webpack-plugin": "^5.5.0",
33
- "tamagui-loader": "1.88.13",
33
+ "tamagui-loader": "1.89.0-1706308641099",
34
34
  "thread-loader": "^4.0.1",
35
35
  "url-loader": "^4.1.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@tamagui/build": "1.88.13",
38
+ "@tamagui/build": "1.89.0-1706308641099",
39
39
  "next": "^14.0.4"
40
40
  },
41
41
  "peerDependencies": {