Skip to content

Commit

Permalink
Use SWC instead of Babel (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel authored Oct 25, 2022
1 parent 0e9be68 commit 0914dcf
Show file tree
Hide file tree
Showing 4 changed files with 1,126 additions and 42 deletions.
25 changes: 0 additions & 25 deletions babel.config.js

This file was deleted.

37 changes: 36 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
const { withSentryConfig } = require('@sentry/nextjs')
const glob = require('glob')
const { dirname, basename, resolve } = require('path')
const { execSync } = require('child_process')

const SentryWebpackPluginOptions = {
Expand All @@ -24,7 +26,12 @@ module.exports = withSentryConfig({
},
]
},

compiler: {
// see https://styled-components.com/docs/tooling#babel-plugin for more info on the options.
styledComponents: {
ssr: true,
},
},
webpack: (config, options) => {
const gitCommitSHAShort = process.env.RUN_GIT_COMMIT_SHA_SHORT ? execSync(process.env.RUN_GIT_COMMIT_SHA_SHORT) : ''
const gitCommitSHA = process.env.RUN_GIT_COMMIT_SHA ? execSync(process.env.RUN_GIT_COMMIT_SHA) : ''
Expand All @@ -44,6 +51,34 @@ module.exports = withSentryConfig({
'process.env.WDYR': JSON.stringify(process.env.WDYR),
})
)

// SVG
config.module.rules.push({
test: /\.svg$/,
issuer: /\.js?$/,
include: [options.dir],
use: [
'next-swc-loader',
{
loader: '@svgr/webpack',
options: { babel: false }
}
],
})

// whyDidYouRender
if (options.dev && !options.isServer) {
const originalEntry = config.entry
config.entry = async () => {
const wdrPath = resolve(__dirname, './scripts/wdyr.js')
const entries = await originalEntry()
if (entries['main.js'] && !entries['main.js'].includes(wdrPath)) {
entries['main.js'].unshift(wdrPath)
}
return entries
}
}

return config
},
productionBrowserSourceMaps: true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"@svgr/webpack": "^6.5.0",
"@welldone-software/why-did-you-render": "^7.0.1",
"babel-plugin-formatjs": "^10.3.25",
"cypress": "^10.6.0",
Expand Down
Loading

1 comment on commit 0914dcf

@vercel
Copy link

@vercel vercel bot commented on 0914dcf Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer – ./

explorer-git-master-ooni1.vercel.app
explorer-one.vercel.app
explorer-ooni1.vercel.app

Please sign in to comment.