Skip to content

Commit 2456665

Browse files
committed
- Update Next.js to version 12
- Update next-transpile-modules to version 9 - Remove .babelrc file - Remove esbuild-loader, path, fs, target, future from next.config.js - Add SWC in next.config.js
1 parent 87be516 commit 2456665

File tree

4 files changed

+740
-3115
lines changed

4 files changed

+740
-3115
lines changed

.babelrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

next.config.js

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
const { ProvidePlugin } = require('webpack');
2-
const { ESBuildMinifyPlugin } = require('esbuild-loader');
1+
const { ProvidePlugin } = require("webpack");
32

43
const bsconfig = require("./bsconfig.json");
5-
const path = require("path");
64
const remarkSlug = require("remark-slug");
7-
const fs = require("fs");
85

96
const transpileModules = ["rescript"].concat(bsconfig["bs-dependencies"]);
107
const withTM = require("next-transpile-modules")(transpileModules);
@@ -16,54 +13,36 @@ const withMdx = require("./plugins/next-mdx")({
1613
},
1714
});
1815

19-
20-
// esbuild-loader specific features
21-
// See: https://github.com/privatenumber/esbuild-loader-examples/blob/master/examples/next/next.config.js
22-
function useEsbuildMinify(config, options) {
23-
const terserIndex = config.optimization.minimizer.findIndex(minimizer => (minimizer.constructor.name === 'TerserPlugin'));
24-
if (terserIndex > -1) {
25-
config.optimization.minimizer.splice(
26-
terserIndex,
27-
1,
28-
new ESBuildMinifyPlugin(options),
29-
);
30-
}
31-
}
32-
33-
const isWebpack5 = true;
3416
const config = {
35-
target: "serverless",
3617
pageExtensions: ["jsx", "js", "bs.js", "mdx", "mjs"],
3718
env: {
3819
ENV: process.env.NODE_ENV,
3920
},
21+
swcMinify: true,
4022
webpack: (config, options) => {
4123
const { isServer } = options;
42-
if (isWebpack5) {
43-
if (!isServer) {
44-
// We shim fs for things like the blog slugs component
45-
// where we need fs access in the server-side part
46-
config.resolve.fallback = {
47-
fs: false,
48-
path: false,
49-
};
50-
}
51-
useEsbuildMinify(config);
52-
// We need this additional rule to make sure that mjs files are
53-
// correctly detected within our src/ folder
54-
config.module.rules.push({
55-
test: /\.m?js$/,
56-
// v-- currently using an experimental setting with esbuild-loader
57-
//use: options.defaultLoaders.babel,
58-
use: [{loader: 'esbuild-loader', options: { loader: 'jsx'}}],
59-
exclude: /node_modules/,
60-
type: "javascript/auto",
61-
resolve: {
62-
fullySpecified: false,
63-
}
64-
});
65-
config.plugins.push(new ProvidePlugin({ React: "react" }));
24+
if (!isServer) {
25+
// We shim fs for things like the blog slugs component
26+
// where we need fs access in the server-side part
27+
config.resolve.fallback = {
28+
fs: false,
29+
path: false,
30+
};
6631
}
32+
// We need this additional rule to make sure that mjs files are
33+
// correctly detected within our src/ folder
34+
config.module.rules.push({
35+
test: /\.m?js$/,
36+
// v-- currently using an experimental setting with esbuild-loader
37+
//use: options.defaultLoaders.babel,
38+
use: [{ loader: "esbuild-loader", options: { loader: "jsx" } }],
39+
exclude: /node_modules/,
40+
type: "javascript/auto",
41+
resolve: {
42+
fullySpecified: false,
43+
},
44+
});
45+
config.plugins.push(new ProvidePlugin({ React: "react" }));
6746
return config;
6847
},
6948
async redirects() {
@@ -80,9 +59,6 @@ const config = {
8059
},
8160
];
8261
},
83-
future: {
84-
webpack5: isWebpack5,
85-
},
8662
};
8763

8864
module.exports = withMdx(withTM(config));

0 commit comments

Comments
 (0)