Replace url
polyfill with self.URL
(#9200)
* Adding native-url package * Bumping native-url version * Upgrading native-url * Logging stats object for debugging * Logging stats object for debugging * Adding try catch to the error lines * Experimenting with regex * Experimenting with regex * Experimenting with regex * Testing regex changes * Fixing defer-script test case to not include polyfill.js * Meging changes with existing polyfill work * Bumping version * adjust webpack config * Reduce size in size test * Remove 1kb from legacy
This commit is contained in:
parent
b6aebf92b7
commit
04a7f1e85d
6 changed files with 23 additions and 6 deletions
|
@ -87,6 +87,9 @@ function getOptimizedAliases(isServer: boolean): { [pkg: string]: string } {
|
|||
'object.assign$': path.join(shimAssign, 'index.js'),
|
||||
'object.assign/polyfill': path.join(shimAssign, 'polyfill.js'),
|
||||
'object.assign/shim': path.join(shimAssign, 'shim.js'),
|
||||
|
||||
// Replace: full URL polyfill with platform-based polyfill
|
||||
url: require.resolve('native-url'),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
import '__next_polyfill__fetch'
|
||||
import 'url-polyfill'
|
||||
Object.assign = require('__next_polyfill__object_assign')
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
"lru-cache": "5.1.1",
|
||||
"mini-css-extract-plugin": "0.8.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"native-url": "0.2.1",
|
||||
"node-fetch": "2.6.0",
|
||||
"object-assign": "4.1.1",
|
||||
"ora": "3.4.0",
|
||||
|
@ -124,6 +125,7 @@
|
|||
"terser": "4.0.0",
|
||||
"unfetch": "4.1.0",
|
||||
"url": "0.11.0",
|
||||
"url-polyfill": "1.1.7",
|
||||
"use-subscription": "1.1.1",
|
||||
"watchpack": "2.0.0-beta.5",
|
||||
"webpack": "4.39.0",
|
||||
|
|
|
@ -45,8 +45,7 @@ describe('Chunking', () => {
|
|||
console.error(stderr)
|
||||
stats = (await readFile(join(appDir, '.next', 'stats.json'), 'utf8'))
|
||||
// fixes backslashes in keyNames not being escaped on windows
|
||||
.replace(/"static\\(.*?":)/g, '"static\\\\$1')
|
||||
.replace(/("static\\.*?)\\pages\\(.*?":)/g, '$1\\\\pages\\\\$2')
|
||||
.replace(/"static\\(.*?":?)/g, match => match.replace(/\\/g, '\\\\'))
|
||||
|
||||
stats = JSON.parse(stats)
|
||||
buildId = await readFile(join(appDir, '.next/BUILD_ID'), 'utf8')
|
||||
|
|
|
@ -81,9 +81,9 @@ describe('Production response size', () => {
|
|||
)
|
||||
|
||||
// These numbers are without gzip compression!
|
||||
const delta = responseSizeKilobytes - 230
|
||||
const delta = responseSizeKilobytes - 229
|
||||
expect(delta).toBeLessThanOrEqual(0) // don't increase size
|
||||
expect(delta).toBeGreaterThanOrEqual(-2) // don't decrease size without updating target
|
||||
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
|
||||
})
|
||||
|
||||
it('should not increase the overall response size of modern build', async () => {
|
||||
|
@ -101,8 +101,8 @@ describe('Production response size', () => {
|
|||
)
|
||||
|
||||
// These numbers are without gzip compression!
|
||||
const delta = responseSizeKilobytes - 204
|
||||
const delta = responseSizeKilobytes - 197
|
||||
expect(delta).toBeLessThanOrEqual(0) // don't increase size
|
||||
expect(delta).toBeGreaterThanOrEqual(-2) // don't decrease size without updating target
|
||||
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
|
||||
})
|
||||
})
|
||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -10537,6 +10537,13 @@ native-or-bluebird@^1.2.0:
|
|||
resolved "https://registry.yarnpkg.com/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz#39c47bfd7825d1fb9ffad32210ae25daadf101c9"
|
||||
integrity sha1-OcR7/Xgl0fuf+tMiEK4l2q3xAck=
|
||||
|
||||
native-url@0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/native-url/-/native-url-0.2.1.tgz#af34e7ade00049a880dbd476f6fc80ffbb4095ef"
|
||||
integrity sha512-1wtxUvRw9yfnqbP/gI7rWnRx3boHosUXz2d+EahWafx86gG0EdxbglqhA6hSKybteH6uLLN867yNmh4cnqndvw==
|
||||
dependencies:
|
||||
querystring "^0.2.0"
|
||||
|
||||
natural-compare@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||
|
@ -15320,6 +15327,11 @@ url-parse-lax@^3.0.0:
|
|||
dependencies:
|
||||
prepend-http "^2.0.0"
|
||||
|
||||
url-polyfill@1.1.7:
|
||||
version "1.1.7"
|
||||
resolved "https://registry.yarnpkg.com/url-polyfill/-/url-polyfill-1.1.7.tgz#402ee84360eb549bbeb585f4c7971e79a31de9e3"
|
||||
integrity sha512-ZrAxYWCREjmMtL8gSbSiKKLZZticgihCvVBtrFbUVpyoETt8GQJeG2okMWA8XryDAaHMjJfhnc+rnhXRbI4DXA==
|
||||
|
||||
url-template@^2.0.8:
|
||||
version "2.0.8"
|
||||
resolved "https://registry.yarnpkg.com/url-template/-/url-template-2.0.8.tgz#fc565a3cccbff7730c775f5641f9555791439f21"
|
||||
|
|
Loading…
Reference in a new issue