@tamagui/next-plugin 1.0.0-beta.225 → 1.0.0-beta.4
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/withTamagui.js +23 -19
- package/dist/cjs/withTamagui.js.map +2 -2
- package/dist/esm/index.js +0 -0
- package/dist/esm/index.js.map +0 -0
- package/dist/esm/withTamagui.js +19 -19
- package/dist/esm/withTamagui.js.map +2 -2
- package/dist/jsx/index.js +0 -0
- package/dist/jsx/withTamagui.js +19 -19
- package/package.json +9 -8
- package/types/withTamagui.d.ts.map +1 -1
- package/LICENSE +0 -21
package/dist/cjs/withTamagui.js
CHANGED
|
@@ -44,6 +44,7 @@ module.exports = __toCommonJS(withTamagui_exports);
|
|
|
44
44
|
var import_path = __toESM(require("path"));
|
|
45
45
|
var import_browserslist = __toESM(require("browserslist"));
|
|
46
46
|
var import_css_minimizer_webpack_plugin = __toESM(require("css-minimizer-webpack-plugin"));
|
|
47
|
+
var import_mini_css_extract_plugin = __toESM(require("mini-css-extract-plugin"));
|
|
47
48
|
var import_css = require("next/dist/build/webpack/config/blocks/css");
|
|
48
49
|
var import_loaders = require("next/dist/build/webpack/config/blocks/css/loaders");
|
|
49
50
|
var import_tamagui_loader = require("tamagui-loader");
|
|
@@ -74,10 +75,8 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
74
75
|
}
|
|
75
76
|
return Object.fromEntries(res);
|
|
76
77
|
}, "safeResolves");
|
|
77
|
-
const alias = __spreadProps(__spreadValues(__spreadValues({}, webpackConfig.resolve.alias || {}), 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", "@
|
|
78
|
-
"react-native-web/src": require.resolve("react-native-web/dist")
|
|
79
|
-
react: require.resolve("react"),
|
|
80
|
-
"react-dom": require.resolve("react-dom")
|
|
78
|
+
const alias = __spreadProps(__spreadValues(__spreadValues({}, webpackConfig.resolve.alias || {}), 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"]])), {
|
|
79
|
+
"react-native-web/src": require.resolve("react-native-web/dist")
|
|
81
80
|
});
|
|
82
81
|
webpackConfig.resolve.alias = alias;
|
|
83
82
|
webpackConfig.plugins.push(new import_webpack.default.DefinePlugin({
|
|
@@ -105,7 +104,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
105
104
|
delete webpackConfig.resolve.plugins[0].paths["tamagui"];
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
|
-
if (!
|
|
107
|
+
if (!dev) {
|
|
109
108
|
const cssMin = webpackConfig.optimization.minimizer.find((x) => x.toString().includes("css-minimizer-plugin"));
|
|
110
109
|
if (cssMin) {
|
|
111
110
|
webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(cssMin.index, 1);
|
|
@@ -162,31 +161,32 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
162
161
|
];
|
|
163
162
|
}
|
|
164
163
|
const oneOfRule = webpackConfig.module.rules.find((x) => !!x.oneOf);
|
|
164
|
+
const cssLoader = (0, import_loaders.getGlobalCssLoader)({
|
|
165
|
+
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
166
|
+
future: nextConfig.future,
|
|
167
|
+
experimental: nextConfig.experimental || {},
|
|
168
|
+
isClient: !isServer,
|
|
169
|
+
isServer,
|
|
170
|
+
isDevelopment: dev
|
|
171
|
+
}, () => (0, import_css.lazyPostCSS)(dir, getSupportedBrowsers(dir, dev)), []);
|
|
165
172
|
if (oneOfRule) {
|
|
166
|
-
if (!dev
|
|
167
|
-
const
|
|
173
|
+
if (!dev) {
|
|
174
|
+
const postCSSLoader = cssLoader[cssLoader.length - 1];
|
|
168
175
|
oneOfRule.oneOf.unshift({
|
|
169
176
|
test: /\.css$/i,
|
|
170
|
-
use: [
|
|
177
|
+
use: [import_mini_css_extract_plugin.default.loader, "css-loader", postCSSLoader],
|
|
171
178
|
sideEffects: true
|
|
172
179
|
});
|
|
173
|
-
|
|
174
|
-
webpackConfig.plugins.splice(idx, 1, new MiniCssExtractPlugin({
|
|
180
|
+
webpackConfig.plugins.push(new import_mini_css_extract_plugin.default({
|
|
175
181
|
filename: "static/css/[name].[contenthash].css",
|
|
176
|
-
ignoreOrder: true
|
|
182
|
+
ignoreOrder: true,
|
|
183
|
+
runtime: false
|
|
177
184
|
}));
|
|
178
185
|
} else {
|
|
179
186
|
oneOfRule.oneOf.unshift({
|
|
180
187
|
test: /\.css$/i,
|
|
181
188
|
sideEffects: true,
|
|
182
|
-
use:
|
|
183
|
-
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
184
|
-
future: nextConfig.future,
|
|
185
|
-
experimental: nextConfig.experimental || {},
|
|
186
|
-
isClient: !isServer,
|
|
187
|
-
isServer,
|
|
188
|
-
isDevelopment: true
|
|
189
|
-
}, () => (0, import_css.lazyPostCSS)(dir, getSupportedBrowsers(dir, dev)), [])
|
|
189
|
+
use: cssLoader
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -267,4 +267,8 @@ function getSupportedBrowsers(dir, isDevelopment) {
|
|
|
267
267
|
return browsers;
|
|
268
268
|
}
|
|
269
269
|
__name(getSupportedBrowsers, "getSupportedBrowsers");
|
|
270
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
271
|
+
0 && (module.exports = {
|
|
272
|
+
withTamagui
|
|
273
|
+
});
|
|
270
274
|
//# sourceMappingURL=withTamagui.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css'\nimport { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/loaders'\nimport { shouldExclude } from 'tamagui-loader'\nimport webpack from 'webpack'\n\nexport type WithTamaguiProps = TamaguiOptions & {\n shouldIncludeModuleServer?: (props: {\n context: string\n request: string\n fullPath: string\n }) => boolean | string | undefined\n}\n\nexport const withTamagui = (tamaguiOptions: WithTamaguiProps) => {\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 // 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 ['react-native-web$', 'react-native-web'],\n ['@testing-library/react-native', '@dish/proxy-worm'],\n ['@gorhom/bottom-sheet$', '@gorhom/bottom-sheet', ['commonjs', 'module']]\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')\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 // replace minifier with css-minimizer-webpack-plugin which handles deduping atomic styles\n if (!isServer && !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 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 if (isServer) {\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n\n const userRes = tamaguiOptions.shouldIncludeModuleServer?.({\n context,\n request,\n fullPath,\n })\n\n if (userRes !== undefined) {\n return userRes\n }\n\n if (\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 = includeModule(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 if (oneOfRule) {\n if (!dev && !isServer) {\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 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 plugins: [\n 'react-native-reanimated/plugin',\n '@babel/plugin-transform-react-jsx',\n ],\n },\n },\n ],\n },\n {\n test: /\\.(jsx?|tsx?)$/,\n exclude: (path: string) => shouldExclude(path, options.dir, tamaguiOptions),\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, tamaguiOptions),\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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,0BAAyB;AACzB,0CAA+B;AAC/B,iBAA4B;AAC5B,qBAAmC;AACnC,4BAA8B;AAC9B,qBAAoB;AAUb,MAAM,cAAc,wBAAC,mBAAqC;AAC/D,SAAO,CAAC,aAAkB,CAAC,MAAM;AAC/B,WAAO,iCACF,aADE;AAAA,MAEL,SAAS,CAAC,eAAoB,YAAiB;
|
|
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 } from 'tamagui-loader'\nimport webpack from 'webpack'\n\nexport type WithTamaguiProps = TamaguiOptions & {\n shouldIncludeModuleServer?: (props: {\n context: string\n request: string\n fullPath: string\n }) => boolean | string | undefined\n}\n\nexport const withTamagui = (tamaguiOptions: WithTamaguiProps) => {\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 // 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 ['react-native-web$', 'react-native-web'],\n ['@testing-library/react-native', '@tamagui/proxy-worm'],\n ['@gorhom/bottom-sheet$', '@gorhom/bottom-sheet', ['commonjs', 'module']]\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')\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 // replace 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 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 if (isServer) {\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n\n const userRes = tamaguiOptions.shouldIncludeModuleServer?.({\n context,\n request,\n fullPath,\n })\n\n if (userRes !== undefined) {\n return userRes\n }\n\n if (\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 = includeModule(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 plugins: [\n 'react-native-reanimated/plugin',\n '@babel/plugin-transform-react-jsx',\n ],\n },\n },\n ],\n },\n {\n test: /\\.(jsx?|tsx?)$/,\n exclude: (path: string) => shouldExclude(path, options.dir, tamaguiOptions),\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, tamaguiOptions),\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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,0BAAyB;AACzB,0CAA+B;AAC/B,qCAAiC;AACjC,iBAA4B;AAC5B,qBAAmC;AACnC,4BAA8B;AAC9B,qBAAoB;AAUb,MAAM,cAAc,wBAAC,mBAAqC;AAC/D,SAAO,CAAC,aAAkB,CAAC,MAAM;AAC/B,WAAO,iCACF,aADE;A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,KAAK,cAAc;AAAA,YAC1E,KAAK;AAAA,cACH,GAAG,CAAC,EAAE,OAAO,UAAU,GAAG;AAAA,cAC1B;AAAA,gBACE,QAAQ;AAAA,gBACR,SAAS;AAAA,cACX;AAAA,YACF;AAAA,UACF,CACF;AAAA,QACF,OAAO;AAEL,gBAAM,CAAC,OAAO,WAAW,QAAQ,cAAc,OAAO;AACtD,wBAAc,OAAO,QAAQ;AAAA,YAC3B;AAAA,YACA;AAAA,YACA;AAAA,cACE,MAAM;AAAA,cACN,SAAS,CAAC,UAAiB,yCAAc,OAAM,QAAQ,KAAK,cAAc;AAAA,cAC1E,KAAK;AAAA,gBACH;AAAA,gBACA;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA,oBACP,QAAQ;AAAA,oBACR,QAAQ;AAAA,kBACV;AAAA,gBACF;AAAA,gBACA;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA,oBACP,YAAY;AAAA,qBACT;AAAA,gBAEP;AAAA,cACF;AAAA,YACF;AAAA,YACA,GAAG;AAAA,UACL;AAAA,QACF;AAEA,YAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAO,WAAW,QAAQ,eAAe,OAAO;AAAA,QAClD;AAEA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,GA9S2B;AAgT3B,8BAA8B,KAAK,eAAe;AAChD,MAAI;AACJ,MAAI;AACF,eAAW,4BAAa,WAAW;AAAA,MACjC,MAAM;AAAA,MACN,KAAK,gBAAgB,gBAAgB;AAAA,IACvC,CAAC;AAAA,EACH,QAAE;AAAA,EAAO;AAET,SAAO;AACT;AAVS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
File without changes
|
package/dist/esm/index.js.map
CHANGED
|
File without changes
|
package/dist/esm/withTamagui.js
CHANGED
|
@@ -3,6 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import browserslist from "browserslist";
|
|
5
5
|
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
6
|
+
import MiniCSSExtractPlugin from "mini-css-extract-plugin";
|
|
6
7
|
import { lazyPostCSS } from "next/dist/build/webpack/config/blocks/css";
|
|
7
8
|
import { getGlobalCssLoader } from "next/dist/build/webpack/config/blocks/css/loaders";
|
|
8
9
|
import { shouldExclude } from "tamagui-loader";
|
|
@@ -36,10 +37,8 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
36
37
|
}, "safeResolves");
|
|
37
38
|
const alias = {
|
|
38
39
|
...webpackConfig.resolve.alias || {},
|
|
39
|
-
...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", "@
|
|
40
|
-
"react-native-web/src": require.resolve("react-native-web/dist")
|
|
41
|
-
react: require.resolve("react"),
|
|
42
|
-
"react-dom": require.resolve("react-dom")
|
|
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")
|
|
43
42
|
};
|
|
44
43
|
webpackConfig.resolve.alias = alias;
|
|
45
44
|
webpackConfig.plugins.push(new webpack.DefinePlugin({
|
|
@@ -67,7 +66,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
67
66
|
delete webpackConfig.resolve.plugins[0].paths["tamagui"];
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
|
-
if (!
|
|
69
|
+
if (!dev) {
|
|
71
70
|
const cssMin = webpackConfig.optimization.minimizer.find((x) => x.toString().includes("css-minimizer-plugin"));
|
|
72
71
|
if (cssMin) {
|
|
73
72
|
webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(cssMin.index, 1);
|
|
@@ -124,31 +123,32 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
124
123
|
];
|
|
125
124
|
}
|
|
126
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)), []);
|
|
127
134
|
if (oneOfRule) {
|
|
128
|
-
if (!dev
|
|
129
|
-
const
|
|
135
|
+
if (!dev) {
|
|
136
|
+
const postCSSLoader = cssLoader[cssLoader.length - 1];
|
|
130
137
|
oneOfRule.oneOf.unshift({
|
|
131
138
|
test: /\.css$/i,
|
|
132
|
-
use: [
|
|
139
|
+
use: [MiniCSSExtractPlugin.loader, "css-loader", postCSSLoader],
|
|
133
140
|
sideEffects: true
|
|
134
141
|
});
|
|
135
|
-
|
|
136
|
-
webpackConfig.plugins.splice(idx, 1, new MiniCssExtractPlugin({
|
|
142
|
+
webpackConfig.plugins.push(new MiniCSSExtractPlugin({
|
|
137
143
|
filename: "static/css/[name].[contenthash].css",
|
|
138
|
-
ignoreOrder: true
|
|
144
|
+
ignoreOrder: true,
|
|
145
|
+
runtime: false
|
|
139
146
|
}));
|
|
140
147
|
} else {
|
|
141
148
|
oneOfRule.oneOf.unshift({
|
|
142
149
|
test: /\.css$/i,
|
|
143
150
|
sideEffects: true,
|
|
144
|
-
use:
|
|
145
|
-
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
146
|
-
future: nextConfig.future,
|
|
147
|
-
experimental: nextConfig.experimental || {},
|
|
148
|
-
isClient: !isServer,
|
|
149
|
-
isServer,
|
|
150
|
-
isDevelopment: true
|
|
151
|
-
}, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
|
|
151
|
+
use: cssLoader
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css'\nimport { getGlobalCssLoader } from 'next/dist/build/webpack/config/blocks/css/loaders'\nimport { shouldExclude } from 'tamagui-loader'\nimport webpack from 'webpack'\n\nexport type WithTamaguiProps = TamaguiOptions & {\n shouldIncludeModuleServer?: (props: {\n context: string\n request: string\n fullPath: string\n }) => boolean | string | undefined\n}\n\nexport const withTamagui = (tamaguiOptions: WithTamaguiProps) => {\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 // 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 ['react-native-web$', 'react-native-web'],\n ['@testing-library/react-native', '@dish/proxy-worm'],\n ['@gorhom/bottom-sheet$', '@gorhom/bottom-sheet', ['commonjs', 'module']]\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')\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 // replace minifier with css-minimizer-webpack-plugin which handles deduping atomic styles\n if (!isServer && !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 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 if (isServer) {\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n\n const userRes = tamaguiOptions.shouldIncludeModuleServer?.({\n context,\n request,\n fullPath,\n })\n\n if (userRes !== undefined) {\n return userRes\n }\n\n if (\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 = includeModule(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 if (oneOfRule) {\n if (!dev && !isServer) {\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 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 plugins: [\n 'react-native-reanimated/plugin',\n '@babel/plugin-transform-react-jsx',\n ],\n },\n },\n ],\n },\n {\n test: /\\.(jsx?|tsx?)$/,\n exclude: (path: string) => shouldExclude(path, options.dir, tamaguiOptions),\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, tamaguiOptions),\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;AAUO,MAAM,cAAc,wBAAC,mBAAqC;AAC/D,SAAO,CAAC,aAAkB,CAAC,MAAM;AAC/B,WAAO;AAAA,SACF;AAAA,MACH,SAAS,CAAC,eAAoB,YAAiB;
|
|
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 } from 'tamagui-loader'\nimport webpack from 'webpack'\n\nexport type WithTamaguiProps = TamaguiOptions & {\n shouldIncludeModuleServer?: (props: {\n context: string\n request: string\n fullPath: string\n }) => boolean | string | undefined\n}\n\nexport const withTamagui = (tamaguiOptions: WithTamaguiProps) => {\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 // 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 ['react-native-web$', 'react-native-web'],\n ['@testing-library/react-native', '@tamagui/proxy-worm'],\n ['@gorhom/bottom-sheet$', '@gorhom/bottom-sheet', ['commonjs', 'module']]\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')\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 // replace 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 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 if (isServer) {\n const includeModule = (context: string, request: string) => {\n const fullPath = request[0] === '.' ? path.join(context, request) : request\n\n const userRes = tamaguiOptions.shouldIncludeModuleServer?.({\n context,\n request,\n fullPath,\n })\n\n if (userRes !== undefined) {\n return userRes\n }\n\n if (\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 = includeModule(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 plugins: [\n 'react-native-reanimated/plugin',\n '@babel/plugin-transform-react-jsx',\n ],\n },\n },\n ],\n },\n {\n test: /\\.(jsx?|tsx?)$/,\n exclude: (path: string) => shouldExclude(path, options.dir, tamaguiOptions),\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, tamaguiOptions),\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;AAUO,MAAM,cAAc,wBAAC,mBAAqC;AAC/D,SAAO,CAAC,aAAkB,CAAC,MAAM;AAC/B,WAAO;AAAA,SACF;AAA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K,cAAc;AAAA,YAC1E,KAAK;AAAA,cACH,GAAG,CAAC,EAAE,OAAO,UAAU,GAAG;AAAA,cAC1B;AAAA,gBACE,QAAQ;AAAA,gBACR,SAAS;AAAA,cACX;AAAA,YACF;AAAA,UACF,CACF;AAAA,QACF,OAAO;AAEL,gBAAM,CAAC,OAAO,WAAW,QAAQ,cAAc,OAAO;AACtD,wBAAc,OAAO,QAAQ;AAAA,YAC3B;AAAA,YACA;AAAA,YACA;AAAA,cACE,MAAM;AAAA,cACN,SAAS,CAAC,UAAiB,cAAc,OAAM,QAAQ,KAAK,cAAc;AAAA,cAC1E,KAAK;AAAA,gBACH;AAAA,gBACA;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA,oBACP,QAAQ;AAAA,oBACR,QAAQ;AAAA,kBACV;AAAA,gBACF;AAAA,gBACA;AAAA,kBACE,QAAQ;AAAA,kBACR,SAAS;AAAA,oBACP,YAAY;AAAA,uBACT;AAAA,kBACL;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,YACA,GAAG;AAAA,UACL;AAAA,QACF;AAEA,YAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAO,WAAW,QAAQ,eAAe,OAAO;AAAA,QAClD;AAEA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,GA9S2B;AAgT3B,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;AAVS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/index.js
CHANGED
|
File without changes
|
package/dist/jsx/withTamagui.js
CHANGED
|
@@ -3,6 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import browserslist from "browserslist";
|
|
5
5
|
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
6
|
+
import MiniCSSExtractPlugin from "mini-css-extract-plugin";
|
|
6
7
|
import { lazyPostCSS } from "next/dist/build/webpack/config/blocks/css";
|
|
7
8
|
import { getGlobalCssLoader } from "next/dist/build/webpack/config/blocks/css/loaders";
|
|
8
9
|
import { shouldExclude } from "tamagui-loader";
|
|
@@ -36,10 +37,8 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
36
37
|
}, "safeResolves");
|
|
37
38
|
const alias = {
|
|
38
39
|
...webpackConfig.resolve.alias || {},
|
|
39
|
-
...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", "@
|
|
40
|
-
"react-native-web/src": require.resolve("react-native-web/dist")
|
|
41
|
-
react: require.resolve("react"),
|
|
42
|
-
"react-dom": require.resolve("react-dom")
|
|
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")
|
|
43
42
|
};
|
|
44
43
|
webpackConfig.resolve.alias = alias;
|
|
45
44
|
webpackConfig.plugins.push(new webpack.DefinePlugin({
|
|
@@ -67,7 +66,7 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
67
66
|
delete webpackConfig.resolve.plugins[0].paths["tamagui"];
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
|
-
if (!
|
|
69
|
+
if (!dev) {
|
|
71
70
|
const cssMin = webpackConfig.optimization.minimizer.find((x) => x.toString().includes("css-minimizer-plugin"));
|
|
72
71
|
if (cssMin) {
|
|
73
72
|
webpackConfig.optimization.minimizer = webpackConfig.optimization.minimizer.slice(cssMin.index, 1);
|
|
@@ -124,31 +123,32 @@ const withTamagui = /* @__PURE__ */ __name((tamaguiOptions) => {
|
|
|
124
123
|
];
|
|
125
124
|
}
|
|
126
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)), []);
|
|
127
134
|
if (oneOfRule) {
|
|
128
|
-
if (!dev
|
|
129
|
-
const
|
|
135
|
+
if (!dev) {
|
|
136
|
+
const postCSSLoader = cssLoader[cssLoader.length - 1];
|
|
130
137
|
oneOfRule.oneOf.unshift({
|
|
131
138
|
test: /\.css$/i,
|
|
132
|
-
use: [
|
|
139
|
+
use: [MiniCSSExtractPlugin.loader, "css-loader", postCSSLoader],
|
|
133
140
|
sideEffects: true
|
|
134
141
|
});
|
|
135
|
-
|
|
136
|
-
webpackConfig.plugins.splice(idx, 1, new MiniCssExtractPlugin({
|
|
142
|
+
webpackConfig.plugins.push(new MiniCSSExtractPlugin({
|
|
137
143
|
filename: "static/css/[name].[contenthash].css",
|
|
138
|
-
ignoreOrder: true
|
|
144
|
+
ignoreOrder: true,
|
|
145
|
+
runtime: false
|
|
139
146
|
}));
|
|
140
147
|
} else {
|
|
141
148
|
oneOfRule.oneOf.unshift({
|
|
142
149
|
test: /\.css$/i,
|
|
143
150
|
sideEffects: true,
|
|
144
|
-
use:
|
|
145
|
-
assetPrefix: options.config.assetPrefix || config.assetPrefix,
|
|
146
|
-
future: nextConfig.future,
|
|
147
|
-
experimental: nextConfig.experimental || {},
|
|
148
|
-
isClient: !isServer,
|
|
149
|
-
isServer,
|
|
150
|
-
isDevelopment: true
|
|
151
|
-
}, () => lazyPostCSS(dir, getSupportedBrowsers(dir, dev)), [])
|
|
151
|
+
use: cssLoader
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/next-plugin",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"typings": "types",
|
|
@@ -18,18 +18,19 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tamagui/proxy-worm": "^1.0.0-beta.
|
|
22
|
-
"@tamagui/static": "^1.0.0-beta.
|
|
21
|
+
"@tamagui/proxy-worm": "^1.0.0-beta.4",
|
|
22
|
+
"@tamagui/static": "^1.0.0-beta.4",
|
|
23
|
+
"babel-loader": "^8.2.5",
|
|
23
24
|
"browserslist": "^4.19.1",
|
|
24
|
-
"css-minimizer-webpack-plugin": "^3.1
|
|
25
|
+
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
25
26
|
"esbuild-loader": "^2.18.0",
|
|
26
27
|
"next-compose-plugins": "^2.2.1",
|
|
27
|
-
"tamagui-loader": "^1.0.0-beta.
|
|
28
|
+
"tamagui-loader": "^1.0.0-beta.4",
|
|
28
29
|
"thread-loader": "^3.0.4"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@tamagui/build": "^1.0.0-beta.
|
|
32
|
-
"next": "^12.1.
|
|
32
|
+
"@tamagui/build": "^1.0.0-beta.4",
|
|
33
|
+
"next": "^12.1.5"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"next": ">=12.0.0"
|
|
@@ -37,5 +38,5 @@
|
|
|
37
38
|
"publishConfig": {
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
|
|
41
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTamagui.d.ts","sourceRoot":"","sources":["../src/withTamagui.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;
|
|
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.
|