Skip to content

Commit b289722

Browse files
authored
feat: update new project templates for Re.Pack 5.2 (#1263)
1 parent ef35799 commit b289722

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

.changeset/ripe-humans-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@callstack/repack": minor
3+
---
4+
5+
Update new project templates for Re.Pack 5.2

templates/rspack.config.cjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@ const Repack = require('@callstack/repack');
77
* Learn about Re.Pack configuration: https://re-pack.dev/docs/guides/configuration
88
*/
99

10-
module.exports = {
10+
module.exports = Repack.defineRspackConfig({
1111
context: __dirname,
1212
entry: './index.js',
1313
resolve: {
1414
...Repack.getResolveOptions(),
1515
},
1616
module: {
1717
rules: [
18-
...Repack.getJsTransformRules(),
18+
{
19+
test: /\.[cm]?[jt]sx?$/,
20+
type: 'javascript/auto',
21+
use: {
22+
loader: '@callstack/repack/babel-swc-loader',
23+
parallel: true,
24+
options: {},
25+
},
26+
},
1927
...Repack.getAssetTransformRules(),
2028
],
2129
},
2230
plugins: [new Repack.RepackPlugin()],
23-
};
31+
});

templates/rspack.config.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,25 @@ const __dirname = path.dirname(__filename);
1212
* Learn about Re.Pack configuration: https://re-pack.dev/docs/guides/configuration
1313
*/
1414

15-
export default {
15+
export default Repack.defineRspackConfig({
1616
context: __dirname,
1717
entry: './index.js',
1818
resolve: {
1919
...Repack.getResolveOptions(),
2020
},
2121
module: {
2222
rules: [
23-
...Repack.getJsTransformRules(),
23+
{
24+
test: /\.[cm]?[jt]sx?$/,
25+
type: 'javascript/auto',
26+
use: {
27+
loader: '@callstack/repack/babel-swc-loader',
28+
parallel: true,
29+
options: {},
30+
},
31+
},
2432
...Repack.getAssetTransformRules(),
2533
],
2634
},
2735
plugins: [new Repack.RepackPlugin()],
28-
};
36+
});

templates/webpack.config.cjs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const Repack = require('@callstack/repack');
2-
const TerserPlugin = require('terser-webpack-plugin');
32

43
/**
54
* Webpack configuration enhanced with Re.Pack defaults for React Native.
@@ -8,7 +7,7 @@ const TerserPlugin = require('terser-webpack-plugin');
87
* Learn about Re.Pack configuration: https://re-pack.dev/docs/guides/configuration
98
*/
109

11-
module.exports = {
10+
module.exports = Repack.defineWebpackConfig({
1211
context: __dirname,
1312
entry: './index.js',
1413
resolve: {
@@ -18,24 +17,14 @@ module.exports = {
1817
rules: [
1918
{
2019
test: /\.[cm]?[jt]sx?$/,
21-
use: 'babel-loader',
2220
type: 'javascript/auto',
21+
use: {
22+
loader: '@callstack/repack/babel-swc-loader',
23+
options: {},
24+
},
2325
},
2426
...Repack.getAssetTransformRules(),
2527
],
2628
},
27-
optimization: {
28-
minimizer: [
29-
new TerserPlugin({
30-
test: /\.(js)?bundle(\?.*)?$/i,
31-
extractComments: false,
32-
terserOptions: {
33-
format: {
34-
comments: false,
35-
},
36-
},
37-
}),
38-
],
39-
},
4029
plugins: [new Repack.RepackPlugin()],
41-
};
30+
});

templates/webpack.config.mjs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from 'node:path';
22
import { fileURLToPath } from 'node:url';
33
import * as Repack from '@callstack/repack';
4-
import TerserPlugin from 'terser-webpack-plugin';
54

65
const __filename = fileURLToPath(import.meta.url);
76
const __dirname = path.dirname(__filename);
@@ -13,7 +12,7 @@ const __dirname = path.dirname(__filename);
1312
* Learn about Re.Pack configuration: https://re-pack.dev/docs/guides/configuration
1413
*/
1514

16-
export default {
15+
export default Repack.defineWebpackConfig({
1716
context: __dirname,
1817
entry: './index.js',
1918
resolve: {
@@ -23,24 +22,14 @@ export default {
2322
rules: [
2423
{
2524
test: /\.[cm]?[jt]sx?$/,
26-
use: 'babel-loader',
2725
type: 'javascript/auto',
26+
use: {
27+
loader: '@callstack/repack/babel-swc-loader',
28+
options: {},
29+
},
2830
},
2931
...Repack.getAssetTransformRules(),
3032
],
3133
},
32-
optimization: {
33-
minimizer: [
34-
new TerserPlugin({
35-
test: /\.(js)?bundle(\?.*)?$/i,
36-
extractComments: false,
37-
terserOptions: {
38-
format: {
39-
comments: false,
40-
},
41-
},
42-
}),
43-
],
44-
},
4534
plugins: [new Repack.RepackPlugin()],
46-
};
35+
});

0 commit comments

Comments
 (0)