Skip to content

Commit

Permalink
Merge branch 'main' into feat/init-custom-version
Browse files Browse the repository at this point in the history
  • Loading branch information
jbroma authored Apr 16, 2024
2 parents c45cef4 + 6c09015 commit 0913d75
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-stingrays-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack": patch
---

Update webpack.config templates
14 changes: 8 additions & 6 deletions packages/TesterApp/webpack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import path from 'path';
import { createRequire } from 'node:module';
import path from 'node:path';
import TerserPlugin from 'terser-webpack-plugin';
import * as Repack from '@callstack/repack';

const dirname = Repack.getDirname(import.meta.url);
const { resolve } = createRequire(import.meta.url);

/**
* More documentation, installation, usage, motivation and differences with Metro is available at:
* https://github.com/callstack/repack/blob/main/README.md
Expand All @@ -20,18 +24,16 @@ import * as Repack from '@callstack/repack';
export default (env) => {
const {
mode = 'development',
context = Repack.getDirname(import.meta.url),
context = dirname,
entry = './index.js',
platform = process.env.PLATFORM,
minimize = mode === 'production',
devServer = undefined,
bundleFilename = undefined,
sourceMapFilename = undefined,
assetsPath = undefined,
reactNativePath = new URL('./node_modules/react-native', import.meta.url)
.pathname,
reactNativePath = resolve('react-native'),
} = env;
const dirname = context;

if (!platform) {
throw new Error('Missing platform');
Expand Down Expand Up @@ -156,7 +158,7 @@ export default (env) => {
/node_modules(.*[/\\])+pretty-format/,
/node_modules(.*[/\\])+metro/,
/node_modules(.*[/\\])+abort-controller/,
/node_modules(.*[/\\])+@callstack\/repack/,
/node_modules(.*[/\\])+@callstack[/\\]repack/,
],
use: 'babel-loader',
},
Expand Down
5 changes: 3 additions & 2 deletions packages/repack/src/webpack/utils/getInitializationEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ export interface InitializationEntriesOptions {
* ```ts
* import * as Repack from '@callstack/repack';
*
* const { resolve } = createRequire(import.meta.url);
*
* export default (env) => {
* const {
* devServer,
* reactNativePath = new URL('./node_modules/react-native', import.meta.url)
* .pathname,
* reactNativePath = resolve('react-native'),
* } = env;
*
* return {
Expand Down
4 changes: 2 additions & 2 deletions templates/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = (env) => {
mode = 'development',
context = __dirname,
entry = './index.js',
platform,
platform = process.env.PLATFORM,
minimize = mode === 'production',
devServer = undefined,
bundleFilename = undefined,
Expand Down Expand Up @@ -157,7 +157,7 @@ module.exports = (env) => {
/node_modules(.*[/\\])+pretty-format/,
/node_modules(.*[/\\])+metro/,
/node_modules(.*[/\\])+abort-controller/,
/node_modules(.*[/\\])+@callstack\/repack/,
/node_modules(.*[/\\])+@callstack[/\\]repack/,
],
use: 'babel-loader',
},
Expand Down
16 changes: 9 additions & 7 deletions templates/webpack.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import path from 'path';
import { createRequire } from 'node:module';
import path from 'node:path';
import TerserPlugin from 'terser-webpack-plugin';
import * as Repack from '@callstack/repack';

const dirname = Repack.getDirname(import.meta.url);
const { resolve } = createRequire(import.meta.url);

/**
* More documentation, installation, usage, motivation and differences with Metro is available at:
* https://github.com/callstack/repack/blob/main/README.md
Expand All @@ -20,24 +24,22 @@ import * as Repack from '@callstack/repack';
export default (env) => {
const {
mode = 'development',
context = Repack.getDirname(import.meta.url),
context = dirname,
entry = './index.js',
platform = process.env.PLATFORM,
minimize = mode === 'production',
devServer = undefined,
bundleFilename = undefined,
sourceMapFilename = undefined,
assetsPath = undefined,
reactNativePath = new URL('./node_modules/react-native', import.meta.url)
.pathname,
reactNativePath = resolve('react-native'),
} = env;
const dirname = Repack.getDirname(import.meta.url);

if (!platform) {
throw new Error('Missing platform');
}

/**
/**
* Using Module Federation might require disabling hmr.
* Uncomment below to set `devServer.hmr` to `false`.
*
Expand Down Expand Up @@ -159,7 +161,7 @@ export default (env) => {
/node_modules(.*[/\\])+pretty-format/,
/node_modules(.*[/\\])+metro/,
/node_modules(.*[/\\])+abort-controller/,
/node_modules(.*[/\\])+@callstack\/repack/,
/node_modules(.*[/\\])+@callstack[/\\]repack/,
],
use: 'babel-loader',
},
Expand Down

0 comments on commit 0913d75

Please sign in to comment.