Skip to content

Commit

Permalink
Ensure modern AMP client page bundles are removed (#12138)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk authored Apr 23, 2020
1 parent 0a3b64d commit 5d13e55
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 188 deletions.
19 changes: 11 additions & 8 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,18 @@ export default async function build(dir: string, conf = null): Promise<void> {
if (result.isAmpOnly) {
// ensure all AMP only bundles got removed
try {
await fsUnlink(
path.join(
distDir,
'static',
buildId,
'pages',
actualPage + '.js'
)
const clientBundle = path.join(
distDir,
'static',
buildId,
'pages',
actualPage + '.js'
)
await fsUnlink(clientBundle)

if (config.experimental.modern) {
await fsUnlink(clientBundle.replace(/\.js$/, '.module.js'))
}
} catch (err) {
if (err.code !== 'ENOENT') {
throw err
Expand Down
1 change: 1 addition & 0 deletions test/integration/amphtml/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ module.exports = {
amp: {
canonicalBase: 'http://localhost:1234',
},
// edit here
}
Loading

0 comments on commit 5d13e55

Please sign in to comment.