From ebfeb31b0fc6016602582cf54bbd6033f0154015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20=C4=90=E1=BB=A9c=20Anh?= <75556609+DuCanhGH@users.noreply.github.com> Date: Thu, 29 Jun 2023 14:46:29 +0700 Subject: [PATCH] Publish packages (#43) Co-authored-by: github-actions[bot] --- .changeset/short-swans-dance.md | 7 --- package.json | 2 +- packages/next-pwa/CHANGELOG.md | 8 ++++ packages/next-pwa/package.json | 2 +- .../webpack-builders/build-custom-worker.ts | 9 +++- .../next-pwa/src/webpack-builders/utils.ts | 6 ++- .../next-sw/src/build/generate-sw/core.ts | 8 ++-- packages/next-sw/src/types.ts | 2 +- pnpm-lock.yaml | 44 +++++++++---------- 9 files changed, 49 insertions(+), 39 deletions(-) delete mode 100644 .changeset/short-swans-dance.md diff --git a/.changeset/short-swans-dance.md b/.changeset/short-swans-dance.md deleted file mode 100644 index 7d41a794..00000000 --- a/.changeset/short-swans-dance.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@ducanh2912/next-pwa": minor ---- - -feat(next-pwa): minify custom workers, sw-entry's workers and fallback workers using swc - -- `next-pwa` should now use swc instead of terser to minify these. diff --git a/package.json b/package.json index f89eb240..ee3c2a2c 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "rimraf": "5.0.1", "shell-quote": "1.8.1", "tslib": "2.6.0", - "turbo": "1.10.6", + "turbo": "1.10.3", "typescript": "5.2.0-dev.20230628", "webpack": "5.88.1" }, diff --git a/packages/next-pwa/CHANGELOG.md b/packages/next-pwa/CHANGELOG.md index c47357be..8a6e49b0 100644 --- a/packages/next-pwa/CHANGELOG.md +++ b/packages/next-pwa/CHANGELOG.md @@ -1,5 +1,13 @@ # @ducanh2912/next-pwa +## 9.1.0 + +### Minor Changes + +- [`0178390`](https://github.com/DuCanhGH/next-pwa/commit/0178390cea97bcbae31bf9ae9da587b93b0e97e5) Thanks [@DuCanhGH](https://github.com/DuCanhGH)! - feat(next-pwa): minify custom workers, sw-entry's workers and fallback workers using swc + + - `next-pwa` should now use swc instead of terser to minify these. + ## 9.0.1 ### Patch Changes diff --git a/packages/next-pwa/package.json b/packages/next-pwa/package.json index 6c1a6718..bddc20cc 100644 --- a/packages/next-pwa/package.json +++ b/packages/next-pwa/package.json @@ -1,6 +1,6 @@ { "name": "@ducanh2912/next-pwa", - "version": "9.0.1", + "version": "9.1.0", "type": "module", "description": "PWA for Next.js, powered by Workbox.", "repository": "https://github.com/DuCanhGH/next-pwa", diff --git a/packages/next-pwa/src/webpack-builders/build-custom-worker.ts b/packages/next-pwa/src/webpack-builders/build-custom-worker.ts index 120fcae3..68f3725e 100644 --- a/packages/next-pwa/src/webpack-builders/build-custom-worker.ts +++ b/packages/next-pwa/src/webpack-builders/build-custom-worker.ts @@ -7,7 +7,7 @@ import { addPathAliasesToSWC, logger } from "utils"; import type { Configuration } from "webpack"; import webpack from "webpack"; -import swcRc from "../.swcrc.json"; +import defaultSwcRc from "../.swcrc.json"; import { NextPWAContext } from "./context.js"; import { getSharedWebpackConfig } from "./utils.js"; @@ -61,6 +61,8 @@ export const buildCustomWorker = ({ logger.info(`Custom worker found: ${customWorkerEntry}`); logger.info(`Building custom worker: ${path.join(destDir, name)}...`); + const swcRc = defaultSwcRc; + if (tsconfig && tsconfig.compilerOptions && tsconfig.compilerOptions.paths) { addPathAliasesToSWC( swcRc, @@ -78,7 +80,10 @@ export const buildCustomWorker = ({ } webpack({ - ...getSharedWebpackConfig({ shouldMinify: NextPWAContext.shouldMinify }), + ...getSharedWebpackConfig({ + swcRc, + shouldMinify: NextPWAContext.shouldMinify, + }), mode: NextPWAContext.shouldMinify ? "production" : "development", target: "webworker", entry: { diff --git a/packages/next-pwa/src/webpack-builders/utils.ts b/packages/next-pwa/src/webpack-builders/utils.ts index 67202f1b..b5aed05b 100644 --- a/packages/next-pwa/src/webpack-builders/utils.ts +++ b/packages/next-pwa/src/webpack-builders/utils.ts @@ -4,15 +4,17 @@ import { fileURLToPath } from "node:url"; import TerserPlugin from "terser-webpack-plugin"; import type { Configuration } from "webpack"; -import swcRc from "../.swcrc.json"; +import defaultSwcRc from "../.swcrc.json"; import { TERSER_OPTIONS } from "./constants.js"; const __dirname = fileURLToPath(new URL(".", import.meta.url)); export const getSharedWebpackConfig = ({ shouldMinify = true, + swcRc = defaultSwcRc, }: { shouldMinify?: boolean; + swcRc?: Record; }): Configuration => { const optimization = shouldMinify && { minimize: true, @@ -25,7 +27,7 @@ export const getSharedWebpackConfig = ({ }; return { resolve: { - extensions: [".js"], + extensions: [".js", ".ts"], fallback: { module: false, dgram: false, diff --git a/packages/next-sw/src/build/generate-sw/core.ts b/packages/next-sw/src/build/generate-sw/core.ts index f1889b01..3d708e0a 100644 --- a/packages/next-sw/src/build/generate-sw/core.ts +++ b/packages/next-sw/src/build/generate-sw/core.ts @@ -8,14 +8,16 @@ import type { Configuration, default as Webpack } from "webpack"; import swcRc from "../../.swcrc.json"; import type { ManifestEntry } from "../../private-types.js"; -import type { FallbackRoutes, RuntimeCaching } from "../../types.js"; +import type { + FallbackRoutes, + ImportScripts, + RuntimeCaching, +} from "../../types.js"; import { getFallbackEnvs } from "./core-utils.js"; import { runtimeCachingConverter } from "./runtime-caching-converter.js"; const __dirname = fileURLToPath(new URL(".", import.meta.url)); -export type ImportScripts = string[] | undefined; - export interface GenerateSWConfig { id: string; mode?: Configuration["mode"]; diff --git a/packages/next-sw/src/types.ts b/packages/next-sw/src/types.ts index a4af75c7..bd04086e 100644 --- a/packages/next-sw/src/types.ts +++ b/packages/next-sw/src/types.ts @@ -1,6 +1,6 @@ import type { Asset, Compilation } from "webpack"; -import type { ImportScripts } from "./build/generate-sw/core.js"; +export type ImportScripts = string[] | undefined; export type FilterEntry = | string diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c535a712..886626ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -78,8 +78,8 @@ importers: specifier: 2.6.0 version: 2.6.0 turbo: - specifier: 1.10.6 - version: 1.10.6 + specifier: 1.10.3 + version: 1.10.3 typescript: specifier: 5.2.0-dev.20230628 version: 5.2.0-dev.20230628 @@ -12021,65 +12021,65 @@ packages: safe-buffer: 5.2.1 dev: false - /turbo-darwin-64@1.10.6: - resolution: {integrity: sha512-s2Gc7i9Ud+H9GDcrGJjPIyscJfzDGQ6il4Sl2snfvwngJs4/TaqKuBoX3HNt/7F4NiFRs7ZhlLV1/Yu9zGBRhw==} + /turbo-darwin-64@1.10.3: + resolution: {integrity: sha512-IIB9IomJGyD3EdpSscm7Ip1xVWtYb7D0x7oH3vad3gjFcjHJzDz9xZ/iw/qItFEW+wGFcLSRPd+1BNnuLM8AsA==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-darwin-arm64@1.10.6: - resolution: {integrity: sha512-tgl70t5PBLyRcNTdP9N6NjvdvQ5LUk8Z60JGUhBhnc+oCOdA4pltrDJNPyel3tQAXXt1dDpl8pp9vUrbwoVyGg==} + /turbo-darwin-arm64@1.10.3: + resolution: {integrity: sha512-SBNmOZU9YEB0eyNIxeeQ+Wi0Ufd+nprEVp41rgUSRXEIpXjsDjyBnKnF+sQQj3+FLb4yyi/yZQckB+55qXWEsw==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-linux-64@1.10.6: - resolution: {integrity: sha512-h7eyAA3xtAVpamcYJYUwe0xm0LWdbv7/I7QiM09AZ67TTNpyUgqW8giFN3h793BHEQ2Rcnk9FNkpIbjWBbyamg==} + /turbo-linux-64@1.10.3: + resolution: {integrity: sha512-kvAisGKE7xHJdyMxZLvg53zvHxjqPK1UVj4757PQqtx9dnjYHSc8epmivE6niPgDHon5YqImzArCjVZJYpIGHQ==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-linux-arm64@1.10.6: - resolution: {integrity: sha512-8cZhOeLqu3QZ27yLd6bw4FNaB8y5pLdWeRLJeiWHkIb/cptKnRKJFP+keBJzJi8ovaMqdBpabrxiBRN2lhau5Q==} + /turbo-linux-arm64@1.10.3: + resolution: {integrity: sha512-Qgaqln0IYRgyL0SowJOi+PNxejv1I2xhzXOI+D+z4YHbgSx87ox1IsALYBlK8VRVYY8VCXl+PN12r1ioV09j7A==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-windows-64@1.10.6: - resolution: {integrity: sha512-qx5jcfCJodN1Mh0KtSVQau7pK8CxDvtif7+joPHI2HbQPAADgdUl0LHfA5tFHh6aWgfvhxbvIXqJd6v7Mqkj9g==} + /turbo-windows-64@1.10.3: + resolution: {integrity: sha512-rbH9wManURNN8mBnN/ZdkpUuTvyVVEMiUwFUX4GVE5qmV15iHtZfDLUSGGCP2UFBazHcpNHG1OJzgc55GFFrUw==} cpu: [x64] os: [win32] requiresBuild: true dev: true optional: true - /turbo-windows-arm64@1.10.6: - resolution: {integrity: sha512-vTQaRG3/s2XTreOBr6J9HKFtjzusvwGQg0GtuW2+9Z7fizdzP8MuhaDbN6FhKHcWC81PQPD61TBIKTVTsYOEZg==} + /turbo-windows-arm64@1.10.3: + resolution: {integrity: sha512-ThlkqxhcGZX39CaTjsHqJnqVe+WImjX13pmjnpChz6q5HHbeRxaJSFzgrHIOt0sUUVx90W/WrNRyoIt/aafniw==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /turbo@1.10.6: - resolution: {integrity: sha512-0/wbjw4HvmPP1abVWHTdeFRfCA9cn5oxCPP5bDixagLzvDgGWE3xfdlsyGmq779Ekr9vjtDPgC2Y4JlXEhyryw==} + /turbo@1.10.3: + resolution: {integrity: sha512-U4gKCWcKgLcCjQd4Pl8KJdfEKumpyWbzRu75A6FCj6Ctea1PIm58W6Ltw1QXKqHrl2pF9e1raAskf/h6dlrPCA==} hasBin: true requiresBuild: true optionalDependencies: - turbo-darwin-64: 1.10.6 - turbo-darwin-arm64: 1.10.6 - turbo-linux-64: 1.10.6 - turbo-linux-arm64: 1.10.6 - turbo-windows-64: 1.10.6 - turbo-windows-arm64: 1.10.6 + turbo-darwin-64: 1.10.3 + turbo-darwin-arm64: 1.10.3 + turbo-linux-64: 1.10.3 + turbo-linux-arm64: 1.10.3 + turbo-windows-64: 1.10.3 + turbo-windows-arm64: 1.10.3 dev: true /typanion@3.12.1: