-
Notifications
You must be signed in to change notification settings - Fork 658
Create actual browser bundles and transpile everything else #789
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f091d22
Create whole browser bundles and transpile everything else
BinaryMuse 4908b2b
Update bundlesize files
BinaryMuse 4a61104
Update babelrc path in Vercel config
BinaryMuse 3e12398
ohh that typo
BinaryMuse a1778a8
Merge remote-tracking branch 'origin/release-19.0.0' into mkt/bundle-up
BinaryMuse 700cd1d
Update entry point
BinaryMuse 365843c
Add exports checker
BinaryMuse 6de2240
Where'd that come from
BinaryMuse d6f959b
Declarated
BinaryMuse 66cbd50
Add `__DEV__` expression for dev mode checks
BinaryMuse 016441c
Merge remote-tracking branch 'origin/release-19.0.0' into mkt/bundle-up
BinaryMuse 37c03c5
Add instructions for importing individual components
BinaryMuse 1a970d7
Add exports tests and massage some exports
BinaryMuse ecbc601
Merge remote-tracking branch 'origin/release-19.0.0' into mkt/bundle-up
BinaryMuse de5f637
Test deprecations and remove in prod
BinaryMuse 06948ae
Add bundle analyzer and make ReactDOM a peer dep
BinaryMuse 2baa3e1
Import polished functions individually to reduce bundle size
BinaryMuse a9445a7
Use actual PropTypes.elementType
BinaryMuse d487b5e
Revert importing polished functions individually
BinaryMuse 0a72ac9
Emit sourcemaps and use them to determine bundle size
BinaryMuse 9db4bd1
I thought I deleted you :fire:
BinaryMuse 5b5bd23
Preval the theme file to drop polished from bundle
BinaryMuse 5a26c6c
Merge branch 'mkt/bundle-up' into mkt/deprecation-testing
BinaryMuse 9bef137
Add notes on silencing deprecation warnings
BinaryMuse 8b77183
what is this??
BinaryMuse 8490287
Transpile to lib/
BinaryMuse 396c3ca
:memo: wordings
BinaryMuse 094df0a
Merge pull request #791 from primer/mkt/deprecation-testing
9bde038
Add cross-env for portable environment variables during builds
BinaryMuse c72014f
Fix rollup's handling of the preval'd theme
BinaryMuse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,4 +3,6 @@ node_modules | |
| .DS_Store | ||
| coverage/ | ||
| dist/ | ||
| lib/ | ||
| public/ | ||
| stats.html | ||
This file contains hidden or 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,13 @@ | ||
| const shared = { | ||
| __DEV__: "process.env.NODE_ENV !== 'production'" | ||
| } | ||
|
|
||
| module.exports = { | ||
| development: shared, | ||
| test: shared, | ||
| production: { | ||
| ...shared, | ||
| __DEV__: 'false', | ||
| 'process.env.NODE_ENV': "'production'" | ||
| } | ||
| } |
This file contains hidden or 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,39 @@ | ||
| const defines = require('./babel-defines') | ||
|
|
||
| function replacementPlugin(env) { | ||
| return ['babel-plugin-transform-replace-expressions', {replace: defines[env]}] | ||
| } | ||
|
|
||
| const sharedPlugins = [ | ||
| 'macros', | ||
| 'preval', | ||
| 'add-react-displayname', | ||
| 'babel-plugin-styled-components', | ||
| '@babel/plugin-proposal-object-rest-spread' | ||
| ] | ||
|
|
||
| const devPlugins = [['@babel/plugin-transform-runtime', {version: '7.9.2', helpers: true}]] | ||
|
|
||
| function makePresets(moduleValue) { | ||
| return [ | ||
| ['@babel/preset-react', {modules: moduleValue}], | ||
| ['@babel/preset-env', {modules: moduleValue}] | ||
| ] | ||
| } | ||
|
|
||
| module.exports = { | ||
| env: { | ||
| development: { | ||
| presets: makePresets('commonjs'), | ||
| plugins: [...sharedPlugins, ...devPlugins, replacementPlugin('development')] | ||
| }, | ||
| production: { | ||
| presets: makePresets(false), | ||
| plugins: [...sharedPlugins, replacementPlugin('production')] | ||
| }, | ||
| test: { | ||
| presets: makePresets('commonjs'), | ||
| plugins: [...sharedPlugins, replacementPlugin('test')] | ||
| } | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 @@ | ||
| const defines = require('../babel-defines') | ||
|
|
||
| exports.onCreateWebpackConfig = ({actions, plugins, loaders, getConfig}) => { | ||
| const config = getConfig() | ||
| // Add our `__DEV__` and `process.env.NODE_ENV` defines | ||
| config.plugins.push(plugins.define(defines[process.env.NODE_ENV || 'development'])) | ||
|
|
||
| config.module.rules = [ | ||
| // Remove the original rule that compiles `.js`. and `.jsx` files... | ||
| ...config.module.rules.filter(rule => String(rule.test) !== String(/\.jsx?$/)), | ||
| // ...and replace it with a custom configuration. | ||
| { | ||
| // The new configuration is based off the original... | ||
| ...loaders.js(), | ||
| test: /\.jsx?$/, | ||
| exclude: modulePath => /node_modules/.test(modulePath), | ||
| // ...except that we want to run Primer Components through webpack as well. | ||
| // By default, Gatsby won't use the define plugin we added above on Primer Components. | ||
| include: modulePath => /@primer\/components/.test(modulePath) | ||
| } | ||
| ] | ||
| actions.replaceWebpackConfig(config) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,18 +1,40 @@ | ||
| import babel from 'rollup-plugin-babel' | ||
| import commonjs from 'rollup-plugin-commonjs' | ||
| import resolve from '@rollup/plugin-node-resolve' | ||
| import {terser} from 'rollup-plugin-terser' | ||
| import visualizer from 'rollup-plugin-visualizer' | ||
|
|
||
| // NOTE: this can be removed once the next version of rollup-plugin-commonjs is released | ||
| const namedExports = { | ||
| 'prop-types': ['object', 'func', 'oneOfType', 'node', 'bool', 'string', 'any', 'arrayOf'], | ||
BinaryMuse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 'react-dom': ['createPortal'], | ||
| 'react-is': ['isValidElementType'] | ||
| } | ||
|
|
||
| const formats = ['esm', 'umd'] // 'cjs' ? | ||
| const plugins = [babel({exclude: 'node_modules/**'}), commonjs()] | ||
| const plugins = [ | ||
| babel({exclude: 'node_modules/**'}), | ||
| resolve(), | ||
| commonjs({namedExports}), | ||
| terser(), | ||
| visualizer({sourcemap: true}) | ||
| ] | ||
|
|
||
| export default [ | ||
| { | ||
| input: 'src/index.js', | ||
| plugins, | ||
| external: ['styled-components', 'react'], | ||
| external: ['styled-components', 'react', 'react-dom'], | ||
| output: formats.map(format => ({ | ||
| file: `dist/index.${format}.js`, | ||
| file: `dist/browser.${format}.js`, | ||
| format, | ||
| name: 'primer' | ||
| sourcemap: true, | ||
| name: 'primer', | ||
| globals: { | ||
| react: 'React', | ||
| 'react-dom': 'ReactDOM', | ||
| 'styled-components': 'styled' | ||
| } | ||
| })) | ||
| } | ||
| ] | ||
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.