Skip to content

Commit

Permalink
fix: Replace too broad regexp in babel-loader config in webpack confi…
Browse files Browse the repository at this point in the history
…g templates (#362)

* fix: Replace too broad regexp in babel-loader config in webpack config templates

* fix: Transpile all react-native related libraries with babel-loader
  • Loading branch information
RafikiTiki authored May 22, 2023
1 parent 47dfe0a commit 0c43fe6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion packages/TesterApp/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export default (env) => {
{
test: /\.[jt]sx?$/,
include: [
/node_modules(.*[/\\])+react/,
/node_modules(.*[/\\])+react\//,
/node_modules(.*[/\\])+react-native/,
/node_modules(.*[/\\])+@react-native/,
/node_modules(.*[/\\])+@react-navigation/,
/node_modules(.*[/\\])+@react-native-community/,
Expand Down
3 changes: 2 additions & 1 deletion templates/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ module.exports = (env) => {
{
test: /\.[jt]sx?$/,
include: [
/node_modules(.*[/\\])+react/,
/node_modules(.*[/\\])+react\//,
/node_modules(.*[/\\])+react-native/,
/node_modules(.*[/\\])+@react-native/,
/node_modules(.*[/\\])+@react-navigation/,
/node_modules(.*[/\\])+@react-native-community/,
Expand Down
5 changes: 3 additions & 2 deletions templates/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default (env) => {
// if (devServer) {
// devServer.hmr = false;
// }

/**
* Depending on your Babel configuration you might want to keep it.
* If you don't use `env` in your Babel config, you can remove it.
Expand Down Expand Up @@ -150,7 +150,8 @@ export default (env) => {
{
test: /\.[jt]sx?$/,
include: [
/node_modules(.*[/\\])+react/,
/node_modules(.*[/\\])+react\//,
/node_modules(.*[/\\])+react-native/,
/node_modules(.*[/\\])+@react-native/,
/node_modules(.*[/\\])+@react-navigation/,
/node_modules(.*[/\\])+@react-native-community/,
Expand Down
14 changes: 8 additions & 6 deletions website/static/diffs/repack_v2-v3.diff
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ index 6ff525d..af917c4 100644
const TerserPlugin = require('terser-webpack-plugin');
-const ReactNative = require('@callstack/repack');
+const Repack = require('@callstack/repack');

/**
* More documentation, installation, usage, motivation and differences with Metro is available at:
@@ -12,292 +11,223 @@ const ReactNative = require('@callstack/repack');
*/

/**
- * This is the Webpack configuration file for your React Native project.
- * It can be used in 2 ways:
Expand Down Expand Up @@ -50,7 +50,7 @@ index 6ff525d..af917c4 100644
+ assetsPath = undefined,
+ reactNativePath = require.resolve('react-native'),
+ } = env;

-const mode = ReactNative.getMode({ fallback: 'development' });
-const dev = mode === 'development';
-const context = ReactNative.getContext();
Expand All @@ -72,7 +72,7 @@ index 6ff525d..af917c4 100644
+ if (!platform) {
+ throw new Error('Missing platform');
+ }

-/**
- * Webpack configuration.
- */
Expand Down Expand Up @@ -229,7 +229,8 @@ index 6ff525d..af917c4 100644
- {
- test: /\.[jt]sx?$/,
- include: [
- /node_modules(.*[/\\])+react/,
- /node_modules(.*[/\\])+react\//,
- /node_modules(.*[/\\])+react-native/,
- /node_modules(.*[/\\])+@react-native/,
- /node_modules(.*[/\\])+@react-navigation/,
- /node_modules(.*[/\\])+@react-native-community/,
Expand Down Expand Up @@ -285,7 +286,8 @@ index 6ff525d..af917c4 100644
+ {
+ test: /\.[jt]sx?$/,
+ include: [
+ /node_modules(.*[/\\])+react/,
+ /node_modules(.*[/\\])+react\//,
+ /node_modules(.*[/\\])+react-native/,
+ /node_modules(.*[/\\])+@react-native/,
+ /node_modules(.*[/\\])+@react-navigation/,
+ /node_modules(.*[/\\])+@react-native-community/,
Expand Down

0 comments on commit 0c43fe6

Please sign in to comment.