@tamagui/next-plugin 1.0.0-beta.8 → 1.0.1-beta.100

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/jsx/index.js CHANGED
@@ -1 +1,6 @@
1
1
  export * from "./withTamagui";
2
+ import { patchReactNativeWeb } from "@tamagui/static";
3
+ export {
4
+ patchReactNativeWeb
5
+ };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './withTamagui'\n\n// this applies automatically already!\n// only exported necessary for weird/advanced use cases, where\n// your react-native-web is in some other directory\nexport { patchReactNativeWeb } from '@tamagui/static'\n"],
5
+ "mappings": "AAAA;AAKA;",
6
+ "names": []
7
+ }
@@ -1,14 +1,20 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  import path from "path";
4
2
  import browserslist from "browserslist";
5
3
  import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
6
4
  import MiniCSSExtractPlugin from "mini-css-extract-plugin";
7
5
  import { lazyPostCSS } from "next/dist/build/webpack/config/blocks/css";
8
6
  import { getGlobalCssLoader } from "next/dist/build/webpack/config/blocks/css/loaders";
9
- import { shouldExclude } from "tamagui-loader";
7
+ import { shouldExclude as shouldExcludeDefault } from "tamagui-loader";
10
8
  import webpack from "webpack";
11
- const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
9
+ const withTamagui = (tamaguiOptions) => {
10
+ const shouldExclude = (path2, projectRoot) => {
11
+ var _a;
12
+ const res = (_a = tamaguiOptions.shouldExtract) == null ? void 0 : _a.call(tamaguiOptions, path2, projectRoot);
13
+ if (typeof res === "boolean") {
14
+ return !res;
15
+ }
16
+ return shouldExcludeDefault(path2, projectRoot);
17
+ };
12
18
  return (nextConfig = {}) => {
13
19
  return {
14
20
  ...nextConfig,
@@ -20,7 +26,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
20
26
  }
21
27
  const isNext12 = typeof ((_a = options.config) == null ? void 0 : _a.swcMinify) === "boolean";
22
28
  const prefix = `${isServer ? " ssr " : " web "} |`;
23
- const safeResolves = /* @__PURE__ */ __name((...resolves) => {
29
+ const safeResolves = (...resolves) => {
24
30
  let res = [];
25
31
  for (const [out, mod, replace] of resolves) {
26
32
  try {
@@ -30,14 +36,16 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
30
36
  }
31
37
  res.push(next);
32
38
  } catch (err) {
33
- console.log(prefix, `withTamagui skipping resolving ${out}`);
34
39
  }
35
40
  }
36
41
  return Object.fromEntries(res);
37
- }, "safeResolves");
42
+ };
38
43
  const alias = {
39
44
  ...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"]]),
45
+ ...safeResolves(["react-native-svg", "react-native-svg-web"], ["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"], ["expo-linear-gradient", "@tamagui/expo-linear-gradient"], ["react-native-web$", "react-native-web"], ["@testing-library/react-native", "@tamagui/proxy-worm"], ["@gorhom/bottom-sheet$", "@gorhom/bottom-sheet", ["commonjs", "module"]], ["react-native/Libraries/Renderer/shims/ReactFabric", "@tamagui/proxy-worm"], ...tamaguiOptions.aliasReactPackages ? [
46
+ ["react", "react"],
47
+ ["react-dom", "react-dom"]
48
+ ] : []),
41
49
  "react-native-web/src": require.resolve("react-native-web/dist")
42
50
  };
43
51
  webpackConfig.resolve.alias = alias;
@@ -51,8 +59,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
51
59
  try {
52
60
  const regexStr = `/react-native-web/.*(${excludeExports.join("|")}).*/`;
53
61
  const regex = new RegExp(regexStr);
54
- console.log(prefix, "exclude", regexStr);
55
- webpackConfig.plugins.push(new webpack.NormalModuleReplacementPlugin(regex, require.resolve("@tamagui/proxy-worm")));
62
+ webpackConfig.plugins.push(new webpack.NormalModuleReplacementPlugin(regex, require.resolve("@tamagui/proxy-worm/empty-react-native-view")));
56
63
  } catch (err) {
57
64
  console.warn(`Invalid names provided to excludeReactNativeWebExports: ${excludeExports.join(", ")}`);
58
65
  }
@@ -73,21 +80,25 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
73
80
  }
74
81
  webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin());
75
82
  }
76
- if (!webpackConfig.resolve.extensions.includes(".web.js")) {
77
- webpackConfig.resolve.extensions = [".web.js", ...webpackConfig.resolve.extensions];
78
- }
83
+ webpackConfig.resolve.extensions = [
84
+ .../* @__PURE__ */ new Set([".web.tsx", ".web.ts", ".web.js", ...webpackConfig.resolve.extensions])
85
+ ];
79
86
  webpackConfig.resolve.mainFields.unshift("module:jsx");
80
87
  if (isServer) {
81
- const includeModule = /* @__PURE__ */ __name((context, request) => {
82
- var _a2;
88
+ const externalize = (context, request) => {
83
89
  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;
90
+ if (tamaguiOptions.shouldExcludeFromServer) {
91
+ const userRes = tamaguiOptions.shouldExcludeFromServer({
92
+ context,
93
+ request,
94
+ fullPath
95
+ });
96
+ if (userRes !== void 0) {
97
+ return userRes;
98
+ }
99
+ }
100
+ if (fullPath === "react-native" || fullPath.startsWith("react-native/")) {
101
+ return false;
91
102
  }
92
103
  if (fullPath.startsWith("react-native-web") || fullPath.includes("node_modules/react-native-web") || /^(react-dom|react)\/$/.test(fullPath)) {
93
104
  return `commonjs ${fullPath}`;
@@ -99,7 +110,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
99
110
  return false;
100
111
  }
101
112
  return true;
102
- }, "includeModule");
113
+ };
103
114
  webpackConfig.externals = [
104
115
  ...webpackConfig.externals.map((external) => {
105
116
  if (typeof external !== "function") {
@@ -107,7 +118,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
107
118
  }
108
119
  return (ctx, cb) => {
109
120
  const isCb = typeof cb === "function";
110
- const res = includeModule(ctx.context, ctx.request);
121
+ const res = externalize(ctx.context, ctx.request);
111
122
  if (isCb) {
112
123
  if (typeof res === "string") {
113
124
  return cb(null, res);
@@ -163,16 +174,14 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
163
174
  {
164
175
  loader: "babel-loader",
165
176
  options: {
166
- plugins: [
167
- "react-native-reanimated/plugin",
168
- "@babel/plugin-transform-react-jsx"
169
- ]
177
+ presets: ["@babel/preset-react"],
178
+ plugins: ["react-native-reanimated/plugin"]
170
179
  }
171
180
  }
172
181
  ]
173
182
  }, {
174
183
  test: /\.(jsx?|tsx?)$/,
175
- exclude: (path2) => shouldExclude(path2, options.dir, tamaguiOptions),
184
+ exclude: (path2) => shouldExclude(path2, options.dir),
176
185
  use: [
177
186
  ...[].concat(swcLoader.use),
178
187
  {
@@ -188,7 +197,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
188
197
  second,
189
198
  {
190
199
  test: /\.(tsx|jsx)$/,
191
- exclude: (path2) => shouldExclude(path2, options.dir, tamaguiOptions),
200
+ exclude: (path2) => shouldExclude(path2, options.dir),
192
201
  use: [
193
202
  "thread-loader",
194
203
  {
@@ -217,7 +226,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
217
226
  }
218
227
  };
219
228
  };
220
- }, "withTamagui");
229
+ };
221
230
  function getSupportedBrowsers(dir, isDevelopment) {
222
231
  let browsers;
223
232
  try {
@@ -229,7 +238,7 @@ function getSupportedBrowsers(dir, isDevelopment) {
229
238
  }
230
239
  return browsers;
231
240
  }
232
- __name(getSupportedBrowsers, "getSupportedBrowsers");
233
241
  export {
234
242
  withTamagui
235
243
  };
244
+ //# 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 type { TamaguiOptions } from '@tamagui/static'\nimport browserslist from 'browserslist'\nimport CssMinimizerPlugin from 'css-minimizer-webpack-plugin'\nimport MiniCSSExtractPlugin from 'mini-css-extract-plugin'\nimport { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css'\nimport { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/loaders'\nimport { shouldExclude as shouldExcludeDefault } from 'tamagui-loader'\nimport webpack from 'webpack'\n\nexport type WithTamaguiProps = TamaguiOptions & {\n aliasReactPackages?: boolean\n shouldExtract?: (path: string, projectRoot: string) => boolean | undefined\n shouldExcludeFromServer?: (props: {\n context: string\n request: string\n fullPath: string\n }) => boolean | string | undefined\n}\n\nexport const withTamagui = (tamaguiOptions: WithTamaguiProps) => {\n // allows configuration\n const shouldExclude = (path: string, projectRoot: string) => {\n const res = tamaguiOptions.shouldExtract?.(path, projectRoot)\n if (typeof res === 'boolean') {\n return !res\n }\n return shouldExcludeDefault(path, projectRoot)\n }\n\n return (nextConfig: any = {}) => {\n return {\n ...nextConfig,\n webpack: (webpackConfig: any, options: any) => {\n const { dir, config, dev, isServer } = options\n\n // @ts-ignore\n if (typeof globalThis['__DEV__'] === 'undefined') {\n // @ts-ignore\n globalThis['__DEV__'] = dev\n }\n\n const isNext12 = typeof options.config?.swcMinify === 'boolean'\n const prefix = `${isServer ? ' ssr ' : ' web '} |`\n\n const safeResolves = (\n ...resolves: ([string, string] | [string, string, [string, string]])[]\n ) => {\n let res: string[][] = []\n for (const [out, mod, replace] of resolves) {\n try {\n const next = [out, require.resolve(mod)]\n if (replace) {\n next[1] = next[1].replace(...replace)\n }\n res.push(next)\n } catch (err) {\n // console.log(prefix, `withTamagui skipping resolving ${out}`)\n }\n }\n return Object.fromEntries(res)\n }\n\n const alias = {\n ...(webpackConfig.resolve.alias || {}),\n ...safeResolves(\n ['react-native-svg', 'react-native-svg-web'],\n // fixes https://github.com/kentcdodds/mdx-bundler/issues/143\n ['react/jsx-runtime.js', 'react/jsx-runtime'],\n ['react/jsx-runtime', 'react/jsx-runtime'],\n ['react/jsx-dev-runtime.js', 'react/jsx-dev-runtime'],\n ['react/jsx-dev-runtime', 'react/jsx-dev-runtime'],\n ['react-native$', 'react-native-web'],\n ['react-native-reanimated', 'react-native-reanimated'],\n ['expo-linear-gradient', '@tamagui/expo-linear-gradient'],\n ['react-native-web$', 'react-native-web'],\n ['@testing-library/react-native', '@tamagui/proxy-worm'],\n ['@gorhom/bottom-sheet$', '@gorhom/bottom-sheet', ['commonjs', 'module']],\n // fix reanimated 3\n ['react-native/Libraries/Renderer/shims/ReactFabric', '@tamagui/proxy-worm'],\n ...(tamaguiOptions.aliasReactPackages\n ? ([\n ['react', 'react'],\n ['react-dom', 'react-dom'],\n ] as any)\n : [])\n ),\n // expo fix https://github.com/expo/expo/issues/9999\n 'react-native-web/src': require.resolve('react-native-web/dist'),\n // react: require.resolve('react'),\n // 'react-dom': require.resolve('react-dom'),\n }\n\n webpackConfig.resolve.alias = alias\n\n webpackConfig.plugins.push(\n new webpack.DefinePlugin({\n 'process.env.IS_STATIC': '\"\"',\n 'process.env.TAMAGUI_TARGET': '\"web\"',\n __DEV__: JSON.stringify(dev),\n })\n )\n\n const excludeExports = tamaguiOptions.excludeReactNativeWebExports\n if (Array.isArray(excludeExports)) {\n try {\n const regexStr = `\\/react-native-web\\/.*(${excludeExports.join('|')}).*\\/`\n const regex = new RegExp(regexStr)\n // console.log(prefix, 'exclude', regexStr)\n webpackConfig.plugins.push(\n new webpack.NormalModuleReplacementPlugin(\n regex,\n require.resolve('@tamagui/proxy-worm/empty-react-native-view')\n )\n )\n } catch (err) {\n console.warn(\n `Invalid names provided to excludeReactNativeWebExports: ${excludeExports.join(', ')}`\n )\n }\n }\n\n if (process.env.IGNORE_TS_CONFIG_PATHS) {\n if (process.env.DEBUG) {\n console.log(prefix, 'ignoring tsconfig paths')\n }\n if (webpackConfig.resolve.plugins[0]) {\n delete webpackConfig.resolve.plugins[0].paths['@tamagui/*']\n delete webpackConfig.resolve.plugins[0].paths['tamagui']\n }\n }\n\n // TODO document and make configurable\n // replaces minifier with css-minimizer-webpack-plugin which handles deduping atomic styles\n if (!dev) {\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\n webpackConfig.resolve.extensions = [\n ...new Set(['.web.tsx', '.web.ts', '.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 if (isServer) {\n const externalize = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n\n if (tamaguiOptions.shouldExcludeFromServer) {\n const userRes = tamaguiOptions.shouldExcludeFromServer({\n context,\n request,\n fullPath,\n })\n if (userRes !== undefined) {\n return userRes\n }\n }\n\n // must inline react-native so we can alias to react-native-web\n if (fullPath === 'react-native' || fullPath.startsWith('react-native/')) {\n return false\n }\n\n if (\n // feather icons uses react-native-svg which needs to be aliased\n // fullPath.includes('/feather-icons/') ||\n fullPath.startsWith('react-native-web') ||\n fullPath.includes('node_modules/react-native-web') ||\n /^(react-dom|react)\\/$/.test(fullPath)\n ) {\n return `commonjs ${fullPath}`\n }\n if (\n fullPath.includes('/moti/') ||\n fullPath.includes('/solito/') ||\n fullPath === 'tamagui' ||\n fullPath.startsWith('@tamagui/') ||\n fullPath === 'react-native-safe-area-context' ||\n fullPath.startsWith('@react-navigation') ||\n fullPath === '@gorhom/bottom-sheet'\n ) {\n return\n }\n if (/^\\@?react-native-/.test(request)) {\n return false\n }\n return true\n }\n\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 return (ctx, cb) => {\n const isCb = typeof cb === 'function'\n const res = externalize(ctx.context, ctx.request)\n if (isCb) {\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 return !res\n ? Promise.resolve(undefined)\n : typeof res === 'string'\n ? Promise.resolve(res)\n : external(ctx)\n }\n }),\n ]\n }\n\n const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf)\n\n const cssLoader = 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: dev,\n },\n // @ts-ignore\n () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)),\n []\n )\n\n if (oneOfRule) {\n if (!dev) {\n const postCSSLoader = cssLoader[cssLoader.length - 1]\n // replace nextjs picky style rules with simple minicssextract\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n use: [MiniCSSExtractPlugin.loader, 'css-loader', postCSSLoader],\n sideEffects: true,\n })\n webpackConfig.plugins.push(\n new MiniCSSExtractPlugin({\n filename: 'static/css/[name].[contenthash].css',\n ignoreOrder: true,\n runtime: false,\n })\n )\n } else {\n oneOfRule.oneOf.unshift({\n test: /\\.css$/i,\n sideEffects: true,\n use: cssLoader,\n })\n }\n }\n\n if (isNext12) {\n const firstOneOfRule = webpackConfig.module.rules.findIndex((x) => x && !!x.oneOf)\n const oneOfJSRules: any[] = webpackConfig.module.rules[firstOneOfRule].oneOf\n const afterSWCLoaderIndex =\n oneOfJSRules.findIndex(\n (x) => x && x.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'\n ) + 1\n const swcLoader = oneOfJSRules[afterSWCLoaderIndex]\n\n // put an earlier loader where we just do tamagui stuff before regular swc\n oneOfJSRules.splice(\n afterSWCLoaderIndex,\n 0,\n {\n test: /(bottom-sheet).*\\.[tj]sx?$/,\n use: [\n {\n loader: 'babel-loader',\n options: {\n presets: ['@babel/preset-react'],\n plugins: ['react-native-reanimated/plugin'],\n },\n },\n ],\n },\n {\n test: /\\.(jsx?|tsx?)$/,\n exclude: (path: string) => shouldExclude(path, options.dir),\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: (path: string) => shouldExclude(path, options.dir),\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: {\n prefixLogs: prefix,\n ...tamaguiOptions,\n },\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;AACA;AACA;AAYO,MA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BAAO,WAAW,QAAQ,eAAe,OAAO;AAAA,QAClD;AAEA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAEA,8BAA8B,KAAK,eAAe;AAChD,MAAI;AACJ,MAAI;AACF,eAAW,aAAa,WAAW;AAAA,MACjC,MAAM;AAAA,MACN,KAAK,gBAAgB,gBAAgB;AAAA,IACvC,CAAC;AAAA,EACH,QAAE;AAAA,EAAO;AAET,SAAO;AACT;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@tamagui/next-plugin",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.1-beta.100",
4
4
  "source": "src/index.ts",
5
5
  "license": "MIT",
6
- "typings": "types",
6
+ "types": "./types/index.d.ts",
7
7
  "main": "dist/cjs",
8
8
  "module": "dist/esm",
9
9
  "module:jsx": "dist/jsx",
10
10
  "files": [
11
+ "src",
11
12
  "types",
12
13
  "dist"
13
14
  ],
@@ -18,19 +19,24 @@
18
19
  "clean:build": "tamagui-build clean:build"
19
20
  },
20
21
  "dependencies": {
21
- "@tamagui/proxy-worm": "^1.0.0-beta.8",
22
- "@tamagui/static": "^1.0.0-beta.8",
22
+ "@babel/preset-react": "^7.16.7",
23
+ "@tamagui/expo-linear-gradient": "^11.2.8",
24
+ "@tamagui/proxy-worm": "^1.0.1-beta.100",
25
+ "@tamagui/static": "^1.0.1-beta.100",
23
26
  "babel-loader": "^8.2.5",
24
- "browserslist": "^4.19.1",
25
- "css-minimizer-webpack-plugin": "^3.4.1",
26
- "esbuild-loader": "^2.18.0",
27
+ "browserslist": "^4.21.1",
28
+ "css-loader": "^5.2.4",
29
+ "css-minimizer-webpack-plugin": "^4.0.0",
30
+ "esbuild-loader": "^2.19.0",
31
+ "mini-css-extract-plugin": "^2.6.0",
27
32
  "next-compose-plugins": "^2.2.1",
28
- "tamagui-loader": "^1.0.0-beta.8",
33
+ "react-native-svg-web": "^1.0.9",
34
+ "tamagui-loader": "^1.0.1-beta.100",
29
35
  "thread-loader": "^3.0.4"
30
36
  },
31
37
  "devDependencies": {
32
- "@tamagui/build": "^1.0.0-beta.8",
33
- "next": "^12.1.5"
38
+ "@tamagui/build": "^1.0.1-beta.100",
39
+ "next": "^12.2.0"
34
40
  },
35
41
  "peerDependencies": {
36
42
  "next": ">=12.0.0"
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './withTamagui'
2
+
3
+ // this applies automatically already!
4
+ // only exported necessary for weird/advanced use cases, where
5
+ // your react-native-web is in some other directory
6
+ export { patchReactNativeWeb } from '@tamagui/static'
@@ -0,0 +1,361 @@
1
+ import path from 'path'
2
+
3
+ import type { TamaguiOptions } from '@tamagui/static'
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 as shouldExcludeDefault } from 'tamagui-loader'
10
+ import webpack from 'webpack'
11
+
12
+ export type WithTamaguiProps = TamaguiOptions & {
13
+ aliasReactPackages?: boolean
14
+ shouldExtract?: (path: string, projectRoot: string) => boolean | undefined
15
+ shouldExcludeFromServer?: (props: {
16
+ context: string
17
+ request: string
18
+ fullPath: string
19
+ }) => boolean | string | undefined
20
+ }
21
+
22
+ export const withTamagui = (tamaguiOptions: WithTamaguiProps) => {
23
+ // allows configuration
24
+ const shouldExclude = (path: string, projectRoot: string) => {
25
+ const res = tamaguiOptions.shouldExtract?.(path, projectRoot)
26
+ if (typeof res === 'boolean') {
27
+ return !res
28
+ }
29
+ return shouldExcludeDefault(path, projectRoot)
30
+ }
31
+
32
+ return (nextConfig: any = {}) => {
33
+ return {
34
+ ...nextConfig,
35
+ webpack: (webpackConfig: any, options: any) => {
36
+ const { dir, config, dev, isServer } = options
37
+
38
+ // @ts-ignore
39
+ if (typeof globalThis['__DEV__'] === 'undefined') {
40
+ // @ts-ignore
41
+ globalThis['__DEV__'] = dev
42
+ }
43
+
44
+ const isNext12 = typeof options.config?.swcMinify === 'boolean'
45
+ const prefix = `${isServer ? ' ssr ' : ' web '} |`
46
+
47
+ const safeResolves = (
48
+ ...resolves: ([string, string] | [string, string, [string, string]])[]
49
+ ) => {
50
+ let res: string[][] = []
51
+ for (const [out, mod, replace] of resolves) {
52
+ try {
53
+ const next = [out, require.resolve(mod)]
54
+ if (replace) {
55
+ next[1] = next[1].replace(...replace)
56
+ }
57
+ res.push(next)
58
+ } catch (err) {
59
+ // console.log(prefix, `withTamagui skipping resolving ${out}`)
60
+ }
61
+ }
62
+ return Object.fromEntries(res)
63
+ }
64
+
65
+ const alias = {
66
+ ...(webpackConfig.resolve.alias || {}),
67
+ ...safeResolves(
68
+ ['react-native-svg', 'react-native-svg-web'],
69
+ // fixes https://github.com/kentcdodds/mdx-bundler/issues/143
70
+ ['react/jsx-runtime.js', 'react/jsx-runtime'],
71
+ ['react/jsx-runtime', 'react/jsx-runtime'],
72
+ ['react/jsx-dev-runtime.js', 'react/jsx-dev-runtime'],
73
+ ['react/jsx-dev-runtime', 'react/jsx-dev-runtime'],
74
+ ['react-native$', 'react-native-web'],
75
+ ['react-native-reanimated', 'react-native-reanimated'],
76
+ ['expo-linear-gradient', '@tamagui/expo-linear-gradient'],
77
+ ['react-native-web$', 'react-native-web'],
78
+ ['@testing-library/react-native', '@tamagui/proxy-worm'],
79
+ ['@gorhom/bottom-sheet$', '@gorhom/bottom-sheet', ['commonjs', 'module']],
80
+ // fix reanimated 3
81
+ ['react-native/Libraries/Renderer/shims/ReactFabric', '@tamagui/proxy-worm'],
82
+ ...(tamaguiOptions.aliasReactPackages
83
+ ? ([
84
+ ['react', 'react'],
85
+ ['react-dom', 'react-dom'],
86
+ ] as any)
87
+ : [])
88
+ ),
89
+ // expo fix https://github.com/expo/expo/issues/9999
90
+ 'react-native-web/src': require.resolve('react-native-web/dist'),
91
+ // react: require.resolve('react'),
92
+ // 'react-dom': require.resolve('react-dom'),
93
+ }
94
+
95
+ webpackConfig.resolve.alias = alias
96
+
97
+ webpackConfig.plugins.push(
98
+ new webpack.DefinePlugin({
99
+ 'process.env.IS_STATIC': '""',
100
+ 'process.env.TAMAGUI_TARGET': '"web"',
101
+ __DEV__: JSON.stringify(dev),
102
+ })
103
+ )
104
+
105
+ const excludeExports = tamaguiOptions.excludeReactNativeWebExports
106
+ if (Array.isArray(excludeExports)) {
107
+ try {
108
+ const regexStr = `\/react-native-web\/.*(${excludeExports.join('|')}).*\/`
109
+ const regex = new RegExp(regexStr)
110
+ // console.log(prefix, 'exclude', regexStr)
111
+ webpackConfig.plugins.push(
112
+ new webpack.NormalModuleReplacementPlugin(
113
+ regex,
114
+ require.resolve('@tamagui/proxy-worm/empty-react-native-view')
115
+ )
116
+ )
117
+ } catch (err) {
118
+ console.warn(
119
+ `Invalid names provided to excludeReactNativeWebExports: ${excludeExports.join(', ')}`
120
+ )
121
+ }
122
+ }
123
+
124
+ if (process.env.IGNORE_TS_CONFIG_PATHS) {
125
+ if (process.env.DEBUG) {
126
+ console.log(prefix, 'ignoring tsconfig paths')
127
+ }
128
+ if (webpackConfig.resolve.plugins[0]) {
129
+ delete webpackConfig.resolve.plugins[0].paths['@tamagui/*']
130
+ delete webpackConfig.resolve.plugins[0].paths['tamagui']
131
+ }
132
+ }
133
+
134
+ // TODO document and make configurable
135
+ // replaces minifier with css-minimizer-webpack-plugin which handles deduping atomic styles
136
+ if (!dev) {
137
+ const cssMin = webpackConfig.optimization.minimizer.find((x) =>
138
+ x.toString().includes('css-minimizer-plugin')
139
+ )
140
+ if (cssMin) {
141
+ webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(
142
+ cssMin.index,
143
+ 1
144
+ )
145
+ }
146
+ webpackConfig.optimization.minimizer.push(new CssMinimizerPlugin())
147
+ }
148
+
149
+ webpackConfig.resolve.extensions = [
150
+ ...new Set(['.web.tsx', '.web.ts', '.web.js', ...webpackConfig.resolve.extensions]),
151
+ ]
152
+
153
+ // look for compiled js with jsx intact as specified by module:jsx
154
+ webpackConfig.resolve.mainFields.unshift('module:jsx')
155
+
156
+ if (isServer) {
157
+ const externalize = (context: string, request: string) => {
158
+ const fullPath = request[0] === '.' ? path.join(context, request) : request
159
+
160
+ if (tamaguiOptions.shouldExcludeFromServer) {
161
+ const userRes = tamaguiOptions.shouldExcludeFromServer({
162
+ context,
163
+ request,
164
+ fullPath,
165
+ })
166
+ if (userRes !== undefined) {
167
+ return userRes
168
+ }
169
+ }
170
+
171
+ // must inline react-native so we can alias to react-native-web
172
+ if (fullPath === 'react-native' || fullPath.startsWith('react-native/')) {
173
+ return false
174
+ }
175
+
176
+ if (
177
+ // feather icons uses react-native-svg which needs to be aliased
178
+ // fullPath.includes('/feather-icons/') ||
179
+ fullPath.startsWith('react-native-web') ||
180
+ fullPath.includes('node_modules/react-native-web') ||
181
+ /^(react-dom|react)\/$/.test(fullPath)
182
+ ) {
183
+ return `commonjs ${fullPath}`
184
+ }
185
+ if (
186
+ fullPath.includes('/moti/') ||
187
+ fullPath.includes('/solito/') ||
188
+ fullPath === 'tamagui' ||
189
+ fullPath.startsWith('@tamagui/') ||
190
+ fullPath === 'react-native-safe-area-context' ||
191
+ fullPath.startsWith('@react-navigation') ||
192
+ fullPath === '@gorhom/bottom-sheet'
193
+ ) {
194
+ return
195
+ }
196
+ if (/^\@?react-native-/.test(request)) {
197
+ return false
198
+ }
199
+ return true
200
+ }
201
+
202
+ // externalize react native things from bundle
203
+ webpackConfig.externals = [
204
+ ...webpackConfig.externals.map((external) => {
205
+ if (typeof external !== 'function') {
206
+ return external
207
+ }
208
+ // only runs on server
209
+ return (ctx, cb) => {
210
+ const isCb = typeof cb === 'function'
211
+ const res = externalize(ctx.context, ctx.request)
212
+ if (isCb) {
213
+ if (typeof res === 'string') {
214
+ return cb(null, res)
215
+ }
216
+ if (res) {
217
+ return external(ctx, cb)
218
+ }
219
+ return cb()
220
+ }
221
+ return !res
222
+ ? Promise.resolve(undefined)
223
+ : typeof res === 'string'
224
+ ? Promise.resolve(res)
225
+ : external(ctx)
226
+ }
227
+ }),
228
+ ]
229
+ }
230
+
231
+ const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf)
232
+
233
+ const cssLoader = getGlobalCssLoader(
234
+ // @ts-ignore
235
+ {
236
+ assetPrefix: options.config.assetPrefix || config.assetPrefix,
237
+ future: nextConfig.future,
238
+ experimental: nextConfig.experimental || {},
239
+ isClient: !isServer,
240
+ isServer,
241
+ isDevelopment: dev,
242
+ },
243
+ // @ts-ignore
244
+ () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)),
245
+ []
246
+ )
247
+
248
+ if (oneOfRule) {
249
+ if (!dev) {
250
+ const postCSSLoader = cssLoader[cssLoader.length - 1]
251
+ // replace nextjs picky style rules with simple minicssextract
252
+ oneOfRule.oneOf.unshift({
253
+ test: /\.css$/i,
254
+ use: [MiniCSSExtractPlugin.loader, 'css-loader', postCSSLoader],
255
+ sideEffects: true,
256
+ })
257
+ webpackConfig.plugins.push(
258
+ new MiniCSSExtractPlugin({
259
+ filename: 'static/css/[name].[contenthash].css',
260
+ ignoreOrder: true,
261
+ runtime: false,
262
+ })
263
+ )
264
+ } else {
265
+ oneOfRule.oneOf.unshift({
266
+ test: /\.css$/i,
267
+ sideEffects: true,
268
+ use: cssLoader,
269
+ })
270
+ }
271
+ }
272
+
273
+ if (isNext12) {
274
+ const firstOneOfRule = webpackConfig.module.rules.findIndex((x) => x && !!x.oneOf)
275
+ const oneOfJSRules: any[] = webpackConfig.module.rules[firstOneOfRule].oneOf
276
+ const afterSWCLoaderIndex =
277
+ oneOfJSRules.findIndex(
278
+ (x) => x && x.use && x.use.loader === 'next-swc-loader' && x.issuerLayer !== 'api'
279
+ ) + 1
280
+ const swcLoader = oneOfJSRules[afterSWCLoaderIndex]
281
+
282
+ // put an earlier loader where we just do tamagui stuff before regular swc
283
+ oneOfJSRules.splice(
284
+ afterSWCLoaderIndex,
285
+ 0,
286
+ {
287
+ test: /(bottom-sheet).*\.[tj]sx?$/,
288
+ use: [
289
+ {
290
+ loader: 'babel-loader',
291
+ options: {
292
+ presets: ['@babel/preset-react'],
293
+ plugins: ['react-native-reanimated/plugin'],
294
+ },
295
+ },
296
+ ],
297
+ },
298
+ {
299
+ test: /\.(jsx?|tsx?)$/,
300
+ exclude: (path: string) => shouldExclude(path, options.dir),
301
+ use: [
302
+ ...[].concat(swcLoader.use),
303
+ {
304
+ loader: 'tamagui-loader',
305
+ options: tamaguiOptions,
306
+ },
307
+ ],
308
+ }
309
+ )
310
+ } else {
311
+ // next 11 modify loader
312
+ const [first, second, ...rest] = webpackConfig.module.rules
313
+ webpackConfig.module.rules = [
314
+ first,
315
+ second,
316
+ {
317
+ test: /\.(tsx|jsx)$/,
318
+ exclude: (path: string) => shouldExclude(path, options.dir),
319
+ use: [
320
+ 'thread-loader',
321
+ {
322
+ loader: 'esbuild-loader',
323
+ options: {
324
+ loader: 'tsx',
325
+ minify: false,
326
+ },
327
+ },
328
+ {
329
+ loader: 'tamagui-loader',
330
+ options: {
331
+ prefixLogs: prefix,
332
+ ...tamaguiOptions,
333
+ },
334
+ },
335
+ ],
336
+ },
337
+ ...rest,
338
+ ]
339
+ }
340
+
341
+ if (typeof nextConfig.webpack === 'function') {
342
+ return nextConfig.webpack(webpackConfig, options)
343
+ }
344
+
345
+ return webpackConfig
346
+ },
347
+ }
348
+ }
349
+ }
350
+
351
+ function getSupportedBrowsers(dir, isDevelopment) {
352
+ let browsers
353
+ try {
354
+ browsers = browserslist.loadConfig({
355
+ path: dir,
356
+ env: isDevelopment ? 'development' : 'production',
357
+ })
358
+ } catch {}
359
+
360
+ return browsers
361
+ }
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './withTamagui';
2
+ export { patchReactNativeWeb } from '@tamagui/static';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAK7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA"}