Skip to content

Commit e583be6

Browse files
committed
fix(disable): fixed disable not working properly
[bump]
1 parent eeefa28 commit e583be6

File tree

23 files changed

+146
-30
lines changed

23 files changed

+146
-30
lines changed

.changeset/witty-needles-talk.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@ducanh2912/next-pwa": patch
3+
---
4+
5+
fix(disable): fixed `disable` not working properly
6+
7+
- In 10.2.0 and 10.2.1, when `disable` is set, some code is still unintendedly run, causing the resulting app to contain some erroneous JavaScript.
8+
- This has been fixed in 10.2.2. Although we still run `parseOptions`, we only do so to get the default options.

examples/reproduction-template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"start": "next start"
1010
},
1111
"dependencies": {
12-
"@ducanh2912/next-pwa": "workspace:*",
12+
"@ducanh2912/next-pwa": "latest",
1313
"next": "canary",
1414
"react": "18.2.0",
1515
"react-dom": "18.2.0"
25.3 KB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const RootLayout = ({ children }: { children: React.ReactNode }) => (
2+
<html lang="en">
3+
<head />
4+
<body>{children}</body>
5+
</html>
6+
);
7+
8+
export default RootLayout;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Image from "next/image";
2+
3+
const Page = () => (
4+
<main>
5+
<p id="welcome-text">This is a Next.js PWA!</p>
6+
<Image src="/next.svg" alt="Next.js Logo" width={180} height={37} priority />
7+
</main>
8+
);
9+
10+
export default Page;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createDescribe } from "../../test-utils/index.ts";
2+
3+
createDescribe("integration disable", { sourceDir: __dirname, skipInstall: false }, ({ next, testMode }) => {
4+
it("should render, have notification, and show no error", async () => {
5+
const $ = await next.render("/");
6+
expect($("#welcome-text").text()).toBe("This is a Next.js PWA!");
7+
expect(next.cliOutput.includes("PWA support is disabled.")).toBe(true);
8+
expect(next.cliOutput.includes("Uncaught ReferenceError")).toBe(false);
9+
});
10+
11+
it("should fetch image", async () => {
12+
const image = await next.fetch("/next.svg");
13+
expect(image.status).toBe(200);
14+
const favicon = await next.fetch("/favicon.ico");
15+
expect(favicon.status).toBe(200);
16+
});
17+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @ts-check
2+
import withPWAInit from "@ducanh2912/next-pwa";
3+
4+
const withPWA = withPWAInit({
5+
dest: "public",
6+
disable: true,
7+
});
8+
9+
/** @type {import('next').NextConfig} */
10+
const nextConfig = {};
11+
12+
export default withPWA(nextConfig);
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"allowImportingTsExtensions": true,
4+
"target": "es5",
5+
"lib": ["dom", "dom.iterable", "esnext"],
6+
"allowJs": true,
7+
"skipLibCheck": true,
8+
"strict": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"noEmit": true,
11+
"esModuleInterop": true,
12+
"module": "esnext",
13+
"moduleResolution": "node",
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"jsx": "preserve",
17+
"incremental": true,
18+
"plugins": [
19+
{
20+
"name": "next"
21+
}
22+
],
23+
"paths": {
24+
"@/*": ["./src/*"]
25+
}
26+
},
27+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
28+
"exclude": ["node_modules"]
29+
}

packages/next-pwa/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"!dist/dts"
1313
],
1414
"source": "./src/index.ts",
15+
"imports": {
16+
"#utils/*.js": "./src/utils/*.ts"
17+
},
1518
"exports": {
1619
".": {
1720
"require": {

0 commit comments

Comments
 (0)