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

Publish packages #43

Merged
merged 3 commits into from
Jun 29, 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: 0 additions & 7 deletions .changeset/short-swans-dance.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/next-pwa/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/next-pwa/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 7 additions & 2 deletions packages/next-pwa/src/webpack-builders/build-custom-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand All @@ -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: {
Expand Down
6 changes: 4 additions & 2 deletions packages/next-pwa/src/webpack-builders/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>;
}): Configuration => {
const optimization = shouldMinify && {
minimize: true,
Expand All @@ -25,7 +27,7 @@ export const getSharedWebpackConfig = ({
};
return {
resolve: {
extensions: [".js"],
extensions: [".js", ".ts"],
fallback: {
module: false,
dgram: false,
Expand Down
8 changes: 5 additions & 3 deletions packages/next-sw/src/build/generate-sw/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
2 changes: 1 addition & 1 deletion packages/next-sw/src/types.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.