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

[Experimental] Nomodule polyfills chunk #10212

Merged
merged 43 commits into from Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1d2d091
Polyfill Promise in polyfills chunk
timneutkens Jan 22, 2020
9015d74
Override promise polyfill to use built-in
timneutkens Jan 22, 2020
b08c2a2
Update sizes
timneutkens Jan 22, 2020
c3f9f77
Update polyfills
timneutkens Jan 23, 2020
c71a723
Test
Timer Jan 24, 2020
fe55d19
Add dep
Timer Jan 24, 2020
89da33b
Use iife
Timer Jan 24, 2020
ab26bce
Unscope
Timer Jan 24, 2020
09791d1
Merge branch 'canary' into polyfilling/test
ijjk Jan 24, 2020
e5d769d
Revert "Unscope"
Timer Jan 24, 2020
7802b7a
trigger
Timer Jan 24, 2020
12d8177
Merge branch 'polyfilling/test' into fix/promise-polyfill-finally
Timer Jan 27, 2020
53eccbe
Merge branch 'canary' into fix/promise-polyfill-finally
Timer Jan 27, 2020
7977e75
Merge branch 'canary' of github.com:zeit/next.js into fix/promise-pol…
timneutkens Jan 27, 2020
19d77a5
Remove unused code
timneutkens Jan 27, 2020
b22a37b
Merge branch 'fix/promise-polyfill-finally' of github.com:timneutkens…
timneutkens Jan 27, 2020
4c2fc0e
Set helpers to true
timneutkens Jan 27, 2020
5c8ff1c
Update yarn.lock
timneutkens Jan 27, 2020
794b73f
Fix test
timneutkens Jan 28, 2020
43fb461
Merge branch 'canary' of github.com:zeit/next.js into fix/promise-pol…
timneutkens Jan 28, 2020
63fbf1d
Update polyfills size
timneutkens Jan 28, 2020
d2d08fb
Add comment
timneutkens Jan 28, 2020
3a0fea9
Add back comment
timneutkens Jan 28, 2020
6821622
Put polyfills optimization under experimental flag
timneutkens Jan 28, 2020
d46e29d
Fix filename
timneutkens Jan 28, 2020
5ccf93d
bring back promise for backwards compat until experimental feature is…
timneutkens Jan 28, 2020
cd0593b
Merge branch 'canary' into fix/promise-polyfill-finally
Timer Jan 30, 2020
9af927e
fix resolve alias check
Timer Jan 30, 2020
a5763e5
correct loader
Timer Jan 30, 2020
1d9863b
fix logic branches
Timer Jan 30, 2020
6dac29e
adjust !!
Timer Jan 30, 2020
00f2766
adjust cache key
Timer Jan 30, 2020
4f593b7
Conditionally branch polyfill
Timer Jan 30, 2020
1b32c41
fix promise polyfill branching
Timer Jan 30, 2020
d1598d6
Re-add runtime
Timer Jan 30, 2020
79d7e4b
fix base object
Timer Jan 30, 2020
387e9c5
fix yarn lock
Timer Jan 30, 2020
ee452a6
Add cache key
Timer Jan 30, 2020
d4386eb
correctly set caller
Timer Jan 30, 2020
1d0f354
add basic test
Timer Jan 30, 2020
5caee6f
Merge branch 'canary' into fix/promise-polyfill-finally
Timer Jan 30, 2020
eb84646
Increment h=>i
Timer Jan 30, 2020
111ec35
increment to j just in case
Timer Jan 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/next/client/index.js
Expand Up @@ -14,13 +14,10 @@ import { isDynamicRoute } from '../next-server/lib/router/utils/is-dynamic'

/// <reference types="react-dom/experimental" />

// Polyfill Promise globally
// This is needed because Webpack's dynamic loading(common chunks) code
// depends on Promise.
// So, we need to polyfill it.
// See: https://webpack.js.org/guides/code-splitting/#dynamic-imports
if (!window.Promise) {
window.Promise = require('@babel/runtime-corejs2/core-js/promise')
// Polyfill finally only as Promise is polyfilled in the polyfills chunk
// Finally is not supported in all module browsers
if (!window.Promise.prototype.finally) {
Timer marked this conversation as resolved.
Show resolved Hide resolved
window.Promise.prototype.finally = require('finally-polyfill')
Timer marked this conversation as resolved.
Show resolved Hide resolved
}

const data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent)
Expand Down
1 change: 1 addition & 0 deletions packages/next/client/polyfills.js
@@ -1,3 +1,4 @@
import 'promise-polyfill/src/polyfill'
import '__next_polyfill__fetch'
import 'url-polyfill'
Object.assign = require('__next_polyfill__object_assign')
2 changes: 2 additions & 0 deletions packages/next/package.json
Expand Up @@ -94,6 +94,7 @@
"devalue": "2.0.1",
"etag": "1.8.1",
"file-loader": "4.2.0",
"finally-polyfill": "0.1.0",
"find-up": "4.0.0",
"fork-ts-checker-webpack-plugin": "3.1.1",
"fresh": "0.5.2",
Expand All @@ -117,6 +118,7 @@
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.7.0",
"promise-polyfill": "8.1.3",
timneutkens marked this conversation as resolved.
Show resolved Hide resolved
"prop-types": "15.7.2",
"prop-types-exact": "1.2.0",
"raw-body": "2.4.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -6512,6 +6512,11 @@ finalhandler@~1.1.2:
statuses "~1.5.0"
unpipe "~1.0.0"

finally-polyfill@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/finally-polyfill/-/finally-polyfill-0.1.0.tgz#2a17b16581d9477db16a703c7b79a898ac0b7d50"
integrity sha512-J1LEcZ5VXe1l3sEO+S//WqL5wcJ/ep7QeKJA6HhNZrcEEFj0eyC8IW3DEZhxySI2bx3r85dwAXz+vYPGuHx5UA==

find-cache-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
Expand Down