Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): remove lazy and importInterop from .swcrc #96

Merged
merged 5 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/lucky-bats-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ducanh2912/next-pwa": patch
---

fix: remove `lazy` and `importInterop` from `.swcrc`

- Seems that these values are no longer allowed with `module.type` set to `"es6"` or `"nodenext"`.
2 changes: 1 addition & 1 deletion docs/content/next-pwa/configuring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default withPWA({

- `browserslist` — Configure supported browsers using Browserslist.

- `buildExcludes` — One or more specifiers used to exclude assets from the precache manifest. This is interpreted following the same rules as Webpack's
- `buildExcludes` — One or more specifiers used to exclude assets from the precache manifest. This is interpreted following the same rules as webpack's
standard `exclude` option. Relative to `.next/static` or your custom build folder.

- `cacheOnFrontendNav` — Enable additional route caching when users navigate through pages with `next/link`.
Expand Down
16 changes: 8 additions & 8 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "workspace:*",
"@mantine/hooks": "6.0.20",
"@mantine/hooks": "7.0.0",
"@tabler/icons-react": "2.34.0",
"bright": "0.8.4",
"client-only": "0.0.1",
"contentlayer": "0.3.4",
"highlight.js": "11.8.0",
"next": "13.4.19",
"next": "13.5.2",
"next-contentlayer": "0.3.4",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand All @@ -28,14 +28,14 @@
},
"devDependencies": {
"@types/extend": "3.0.1",
"@types/hast": "3.0.0",
"@types/hast": "3.0.1",
"@types/mdast": "4.0.0",
"@types/mdx": "2.0.7",
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"@types/uuid": "9.0.4",
"autoprefixer": "10.4.15",
"autoprefixer": "10.4.16",
"extend": "3.0.2",
"github-slugger": "2.0.0",
"hast-util-has-property": "3.0.0",
Expand All @@ -45,11 +45,11 @@
"mdast-util-to-markdown": "2.1.0",
"mdast-util-to-string": "4.0.0",
"mdx-bundler": "9.2.1",
"postcss": "8.4.29",
"postcss": "8.4.30",
"rehype-highlight": "7.0.0",
"rehype-sanitize": "6.0.0",
"tailwindcss": "3.3.3",
"typescript": "5.3.0-dev.20230915",
"typescript": "5.3.0-dev.20230921",
"unified": "10.1.2",
"unist-util-is": "6.0.0",
"unist-util-visit": "5.0.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"typescript": "5.2.2"
}
Expand Down
8 changes: 4 additions & 4 deletions examples/custom-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"@fastify/compress": "6.4.0",
"cross-env": "7.0.3",
"fastify": "4.23.2",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@swc/core": "1.3.78",
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@swc/core": "1.3.86",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"nodemon": "3.0.1",
"rimraf": "5.0.1",
Expand Down
6 changes: 3 additions & 3 deletions examples/custom-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"typescript": "5.2.2"
}
Expand Down
6 changes: 3 additions & 3 deletions examples/lifecycle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"typescript": "5.2.2"
}
Expand Down
6 changes: 3 additions & 3 deletions examples/next-i18next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"express": "4.18.2",
"fastify-compress": "4.1.0",
"i18next": "23.5.1",
"next": "13.4.19",
"next": "13.5.2",
"next-i18next": "14.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-i18next": "13.2.2"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"typescript": "5.2.2"
}
Expand Down
6 changes: 3 additions & 3 deletions examples/next-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"typescript": "5.2.2"
}
Expand Down
8 changes: 4 additions & 4 deletions examples/offline-fallback-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"sharp": "0.32.5"
"sharp": "0.32.6"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"typescript": "5.2.2"
}
Expand Down
6 changes: 3 additions & 3 deletions examples/web-push/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
},
"dependencies": {
"@ducanh2912/next-pwa": "latest",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"web-push": "3.6.6"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"@types/web-push": "3.6.0",
"typescript": "5.2.2"
Expand Down
6 changes: 3 additions & 3 deletions examples/workboxless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
"dependencies": {
"@ducanh2912/next-sw": "latest",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"typescript": "5.2.2"
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"@changesets/cli": "2.26.2",
"@ducanh2912/next-pwa": "workspace:*",
"@ducanh2912/next-sw": "workspace:*",
"@types/node": "20.6.1",
"@types/node": "20.6.3",
"@types/shell-quote": "1.7.1",
"@typescript-eslint/eslint-plugin": "6.7.0",
"@typescript-eslint/parser": "6.7.0",
"@typescript-eslint/eslint-plugin": "6.7.2",
"@typescript-eslint/parser": "6.7.2",
"cross-env": "7.0.3",
"eslint": "8.49.0",
"eslint-config-next": "13.4.19",
"eslint-config-next": "13.5.2",
"eslint-config-prettier": "9.0.0",
"eslint-config-turbo": "1.10.14",
"eslint-plugin-import": "2.28.1",
Expand All @@ -49,14 +49,14 @@
"husky": "8.0.3",
"jest": "29.7.0",
"lint-staged": "14.0.1",
"npm-check-updates": "16.14.3",
"npm-check-updates": "16.14.4",
"prettier": "3.0.3",
"prettier-plugin-tailwindcss": "0.5.4",
"rimraf": "5.0.1",
"shell-quote": "1.8.1",
"tslib": "2.6.2",
"turbo": "1.10.14",
"typescript": "5.3.0-dev.20230915"
"typescript": "5.3.0-dev.20230921"
},
"packageManager": "[email protected]"
}
2 changes: 1 addition & 1 deletion packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
}
},
"devDependencies": {
"@swc/core": "1.3.78"
"@swc/core": "1.3.86"
}
}
5 changes: 0 additions & 5 deletions packages/constants/src/swc-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
export const swcConfig = {
module: {
type: "nodenext",
lazy: true,
importInterop: "swc",
},
jsc: {
minify: {
Expand All @@ -31,9 +29,6 @@ export const swcConfig = {
dynamicImport: true,
decorators: false,
},
transform: {
react: undefined,
},
target: "esnext",
loose: false,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/next-pwa/__tests__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "next-pwa-tests",
"version": "1.0.0",
"private": true,
"type": "module",
"devDependencies": {
"@types/jest": "29.5.5",
"@types/react": "18.2.21",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"tests-utils": "workspace:*"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/next-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@
"@rollup/plugin-node-resolve": "15.2.1",
"@rollup/plugin-swc": "0.2.0",
"@rollup/plugin-typescript": "11.1.3",
"@swc/core": "1.3.78",
"@types/node": "20.6.1",
"@swc/core": "1.3.86",
"@types/node": "20.6.3",
"@types/semver": "7.5.2",
"chalk": "5.3.0",
"next": "13.4.19",
"next": "13.5.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"rollup": "3.28.1",
"rollup-plugin-dts": "6.0.2",
"type-fest": "4.3.1",
"typescript": "5.3.0-dev.20230915",
"typescript": "5.3.0-dev.20230921",
"webpack": "5.88.2"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-pwa/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface PluginOptions {
browserslist?: BrowserslistOptions;
/**
* One or more specifiers used to exclude assets from the precache manifest.
* This is interpreted following the same rules as Webpack's standard `exclude`
* This is interpreted following the same rules as webpack's standard `exclude`
* option. Relative to `.next/static` or your custom build folder. Defaults to
* [].
* @example
Expand Down
13 changes: 5 additions & 8 deletions packages/next-pwa/src/webpack-builders/.swcrc.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import type { Options } from "@swc/core";

/**
* Our default `.swcrc`. Manually inject `env.targets` before use (this is done
* automatically if you use `getSharedWebpackConfig`).
*/
export const defaultSwcRc: Options = {
module: {
type: "es6",
lazy: true,
noInterop: true,
},
jsc: {
parser: {
syntax: "typescript",
tsx: true,
tsx: false,
dynamicImport: true,
decorators: false,
},
transform: {
react: {
runtime: "automatic",
},
},
loose: false,
},
minify: false,
Expand Down
13 changes: 7 additions & 6 deletions packages/next-pwa/src/webpack-builders/build-custom-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const buildCustomWorker = ({
);
}

// We'd like to use Webpack's `[hash]`, but we can't determine that hash without
// We'd like to use webpack's `[hash]`, but we can't determine that hash without
// Promise (Next doesn't allow Promise in webpack(config, context), but even if we
// use Promise we will block the build until our stuff is done)
const name = `${customWorkerPrefix}-${getContentHash(
Expand Down Expand Up @@ -117,16 +117,17 @@ export const buildCustomWorker = ({

webpack(webpackConfig, (error, status) => {
if (error || status?.hasErrors()) {
logger.error("Failed to compile the custom worker.");
logger.error("Failed to build the custom worker.");
logger.error(
status?.toString({ colors: true }) ?? error?.message ?? "Unknown error"
);
if (!isDev) {
process.exit(-1);
}
if (!isDev)
throw new Error(
"Failed to build the custom worker due to webpack errors."
);
} else {
logger.event(
`Compiled the custom worker successfully! (${
`Built the custom worker successfully! (${
status?.compilation.modules.size ?? 0
} modules)`
);
Expand Down
Loading