forked from shadowwalker/next-pwa
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mjs): fixed the ESM build crashing
[bump]
- Loading branch information
Showing
12 changed files
with
109 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@ducanh2912/next-pwa": patch | ||
--- | ||
|
||
fix(mjs): fixed the ESM build crashing | ||
|
||
- This was due to us referencing `__dirname`, which was `undefined` in the ESM build... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const RootLayout = ({ children }: { children: React.ReactNode }) => ( | ||
<html lang="en"> | ||
<head /> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
|
||
export default RootLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Image from "next/image"; | ||
|
||
const Page = () => ( | ||
<main> | ||
<p id="welcome-text">This is a Next.js PWA!</p> | ||
<Image src="/next.svg" alt="Next.js Logo" width={180} height={37} priority /> | ||
</main> | ||
); | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { createDescribe } from "../../test-utils/index.ts"; | ||
|
||
createDescribe("e2e app-dir", { sourceDir: __dirname, skipInstall: false }, ({ next }) => { | ||
it("should render", async () => { | ||
const $ = await next.render("/"); | ||
expect($("#welcome-text").text()).toBe("This is a Next.js PWA!"); | ||
}); | ||
|
||
it("should fetch image", async () => { | ||
const image = await next.fetch("/next.svg"); | ||
expect(image.status).toBe(200); | ||
const favicon = await next.fetch("/favicon.ico"); | ||
expect(favicon.status).toBe(200); | ||
}); | ||
|
||
it("should be able to fetch service worker", async () => { | ||
const sw = await next.fetch("/sw.js"); | ||
expect(sw.status).toBe(200); | ||
expect(sw.headers.get("Content-Type")?.includes("application/javascript")).toBe(true); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/next-pwa/__tests__/integration/mjs/next.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @ts-check | ||
import withPWAInit from "@ducanh2912/next-pwa"; | ||
|
||
const withPWA = withPWAInit({ | ||
dest: "public", | ||
}); | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
|
||
export default withPWA(nextConfig); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowImportingTsExtensions": true, | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
], | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ packages: | |
- "docs" | ||
- "packages/**" | ||
- "examples/**" | ||
- "!examples/**/.next" | ||
- "!**/.next" | ||
- "next-pwa-e2e-test" |