-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Experimental] Nomodule polyfills chunk (#10212)
* Polyfill Promise in polyfills chunk * Override promise polyfill to use built-in * Update sizes * Update polyfills * Test * Add dep * Use iife * Unscope * Revert "Unscope" This reverts commit ab26bce. * trigger * Remove unused code * Set helpers to true * Update yarn.lock * Fix test * Update polyfills size * Add comment * Add back comment * Put polyfills optimization under experimental flag * Fix filename * bring back promise for backwards compat until experimental feature is landed * fix resolve alias check * correct loader * fix logic branches * adjust !! * adjust cache key * Conditionally branch polyfill * fix promise polyfill branching * Re-add runtime * fix base object * fix yarn lock * Add cache key * correctly set caller * add basic test * Increment h=>i * increment to j just in case Co-authored-by: Joe Haddad <[email protected]> Co-authored-by: JJ Kasper <[email protected]>
- Loading branch information
1 parent
e6f401c
commit e35005c
Showing
12 changed files
with
1,519 additions
and
78 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,19 @@ | ||
{ | ||
"name": "@next/polyfill-nomodule", | ||
"version": "0.0.0", | ||
"description": "A polyfill for non-dead, nomodule browsers.", | ||
"main": "dist/polyfill-nomodule.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"prepublish": "microbundle src/index.js -f iife --no-sourcemap --external none", | ||
"build": "microbundle watch src/index.js -f iife --no-sourcemap --external none" | ||
}, | ||
"devDependencies": { | ||
"core-js": "3.6.4", | ||
"microbundle": "0.11.0", | ||
"object-assign": "4.1.1", | ||
"promise-polyfill": "8.1.3", | ||
"url-polyfill": "1.1.7", | ||
"whatwg-fetch": "3.0.0" | ||
} | ||
} |
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,67 @@ | ||
import 'core-js/modules/es6.array.copy-within' | ||
import 'core-js/modules/es6.array.fill' | ||
import 'core-js/modules/es6.array.find' | ||
import 'core-js/modules/es6.array.find-index' | ||
import 'core-js/modules/es7.array.flat-map' | ||
import 'core-js/modules/es6.array.from' | ||
import 'core-js/modules/es7.array.includes' | ||
import 'core-js/modules/es6.array.iterator' | ||
import 'core-js/modules/es6.array.of' | ||
import 'core-js/modules/es6.array.species' | ||
import 'core-js/modules/es6.function.has-instance' | ||
import 'core-js/modules/es6.map' | ||
import 'core-js/modules/es6.number.constructor' | ||
import 'core-js/modules/es6.number.epsilon' | ||
import 'core-js/modules/es6.number.is-finite' | ||
import 'core-js/modules/es6.number.is-integer' | ||
import 'core-js/modules/es6.number.is-nan' | ||
import 'core-js/modules/es6.number.is-safe-integer' | ||
import 'core-js/modules/es6.number.max-safe-integer' | ||
import 'core-js/modules/es6.number.min-safe-integer' | ||
import 'core-js/modules/es7.object.entries' | ||
import 'core-js/modules/es7.object.get-own-property-descriptors' | ||
import 'core-js/modules/es6.object.is' | ||
import 'core-js/modules/es7.object.values' | ||
import 'core-js/modules/es6.reflect.apply' | ||
import 'core-js/modules/es6.reflect.construct' | ||
import 'core-js/modules/es6.reflect.define-property' | ||
import 'core-js/modules/es6.reflect.delete-property' | ||
import 'core-js/modules/es6.reflect.get' | ||
import 'core-js/modules/es6.reflect.get-own-property-descriptor' | ||
import 'core-js/modules/es6.reflect.get-prototype-of' | ||
import 'core-js/modules/es6.reflect.has' | ||
import 'core-js/modules/es6.reflect.is-extensible' | ||
import 'core-js/modules/es6.reflect.own-keys' | ||
import 'core-js/modules/es6.reflect.prevent-extensions' | ||
import 'core-js/modules/es6.reflect.set' | ||
import 'core-js/modules/es6.reflect.set-prototype-of' | ||
import 'core-js/modules/es6.regexp.constructor' | ||
import 'core-js/modules/es6.regexp.flags' | ||
import 'core-js/modules/es6.regexp.match' | ||
import 'core-js/modules/es6.regexp.replace' | ||
import 'core-js/modules/es6.regexp.split' | ||
import 'core-js/modules/es6.regexp.search' | ||
import 'core-js/modules/es6.set' | ||
import 'core-js/modules/es6.symbol' | ||
import 'core-js/modules/es7.symbol.async-iterator' | ||
import 'core-js/modules/es6.string.code-point-at' | ||
import 'core-js/modules/es6.string.ends-with' | ||
import 'core-js/modules/es6.string.from-code-point' | ||
import 'core-js/modules/es6.string.includes' | ||
import 'core-js/modules/es6.string.iterator' | ||
import 'core-js/modules/es7.string.pad-start' | ||
import 'core-js/modules/es7.string.pad-end' | ||
import 'core-js/modules/es6.string.raw' | ||
import 'core-js/modules/es6.string.repeat' | ||
import 'core-js/modules/es6.string.starts-with' | ||
import 'core-js/modules/es7.string.trim-left' | ||
import 'core-js/modules/es7.string.trim-right' | ||
import 'core-js/modules/es6.weak-map' | ||
import 'core-js/modules/es6.weak-set' | ||
|
||
// Specialized Packages: | ||
import 'promise-polyfill/src/polyfill' | ||
import 'whatwg-fetch' | ||
import 'url-polyfill' | ||
import assign from 'object-assign' | ||
Object.assign = assign |
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
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
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 @@ | ||
import '@next/polyfill-nomodule' |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
polyfillsOptimization: true, | ||
}, | ||
} |
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 @@ | ||
export default () => <p>hi</p> |
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,23 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import { remove } from 'fs-extra' | ||
import { nextBuild } from 'next-test-utils' | ||
import { join } from 'path' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 | ||
|
||
const appDir = join(__dirname, '../') | ||
|
||
describe('Polyfilling (minimal)', () => { | ||
beforeAll(async () => { | ||
await remove(join(appDir, '.next')) | ||
}) | ||
|
||
it('should compile successfully', async () => { | ||
const { code, stdout } = await nextBuild(appDir, [], { | ||
stdout: true, | ||
}) | ||
expect(code).toBe(0) | ||
expect(stdout).toMatch(/Compiled successfully/) | ||
}) | ||
}) |
Oops, something went wrong.