Skip to content

Commit

Permalink
babel loader, lodash, postcss externalize
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jan 14, 2021
1 parent 0e9fdc0 commit ea2c174
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/babel/preset.ts
Expand Up @@ -198,7 +198,7 @@ module.exports = (
],
require('./plugins/amp-attributes'),
isProduction && [
require('babel-plugin-transform-react-remove-prop-types'),
require('next/dist/compiled/babel-plugin-transform-react-remove-prop-types'),
{
removeImport: true,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/webpack/loaders/next-babel-loader.js
Expand Up @@ -155,7 +155,7 @@ const customBabelLoader = babelLoader((babel) => {
}

options.plugins.push([
require.resolve('babel-plugin-transform-define'),
require.resolve('next/dist/compiled/babel-plugin-transform-define'),
{
'process.env.NODE_ENV': development ? 'development' : 'production',
'typeof window': isServer ? 'undefined' : 'object',
Expand Down
8 changes: 8 additions & 0 deletions packages/next/compiled/babel-plugin-transform-define/LICENSE
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Formidable

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Large diffs are not rendered by default.

@@ -0,0 +1 @@
{"name":"babel-plugin-transform-define","main":"index.js","license":"MIT"}
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Nikita Gusakov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1 @@
{"name":"babel-plugin-transform-react-remove-prop-types","main":"index.js","author":"Nikita Gusakov","license":"MIT"}
47 changes: 47 additions & 0 deletions packages/next/compiled/lodash/LICENSE
@@ -0,0 +1,47 @@
Copyright OpenJS Foundation and other contributors <https://openjsf.org/>

Based on Underscore.js, copyright Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>

This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/lodash/lodash

The following license applies to all parts of this software except as
documented below:

====

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

====

Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code displayed within the prose of the
documentation.

CC0: http://creativecommons.org/publicdomain/zero/1.0/

====

Files located in the node_modules and vendor directories are externally
maintained libraries used by this software which have their own
licenses; we recommend you read them, as their terms may differ from the
terms above.
1 change: 1 addition & 0 deletions packages/next/compiled/lodash/lodash.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/next/compiled/lodash/package.json
@@ -0,0 +1 @@
{"name":"lodash","main":"lodash.js","author":"John-David Dalton <john.david.dalton@gmail.com>","license":"MIT"}
2 changes: 1 addition & 1 deletion packages/next/compiled/postcss-flexbugs-fixes/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/postcss-loader/cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/postcss-preset-env/index.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/next/package.json
Expand Up @@ -69,8 +69,6 @@
"@next/react-refresh-utils": "10.0.6-canary.1",
"@opentelemetry/api": "0.14.0",
"ast-types": "0.13.2",
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"browserslist": "4.14.6",
"buffer": "5.6.0",
"caniuse-lite": "^1.0.30001113",
Expand Down Expand Up @@ -180,6 +178,8 @@
"async-retry": "1.2.3",
"async-sema": "3.0.0",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"cacache": "15.0.5",
"cache-loader": "4.1.0",
"ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
Expand All @@ -204,6 +204,7 @@
"jsonwebtoken": "8.5.1",
"loader-utils": "2.0.0",
"lodash.curry": "4.1.1",
"lodash": "4.17.20",
"lru-cache": "5.1.1",
"mkdirp": "0.5.3",
"nanoid": "3.1.20",
Expand Down
46 changes: 45 additions & 1 deletion packages/next/taskfile.js
Expand Up @@ -38,13 +38,14 @@ const externals = {
'caniuse-lite': 'caniuse-lite', // FIXME: `autoprefixer` will still bundle this because it uses direct imports

chalk: 'chalk',
lodash: 'lodash',
'node-fetch': 'node-fetch',

// webpack
'node-libs-browser': 'node-libs-browser',

// css-loader
// postcss: 'postcss',
postcss: 'postcss',

// sass-loader
// (also responsible for these dependencies in package.json)
Expand Down Expand Up @@ -141,6 +142,38 @@ export async function ncc_babel_bundle_packages(task, opts) {
.target('compiled/babel/')
}

// eslint-disable-next-line camelcase
externals['babel-plugin-transform-define'] =
'next/dist/compiled/babel-plugin-transform-define'
export async function ncc_babel_plugin_transform_define(task, opts) {
await task
.source(
opts.src ||
relative(__dirname, require.resolve('babel-plugin-transform-define'))
)
.ncc({ packageName: 'babel-plugin-transform-define' })
.target('compiled/babel-plugin-transform-define')
}

// eslint-disable-next-line camelcase
externals['babel-plugin-transform-react-remove-prop-types'] =
'next/dist/compiled/babel-plugin-transform-react-remove-prop-types'
export async function ncc_babel_plugin_transform_react_remove_prop_types(
task,
opts
) {
await task
.source(
opts.src ||
relative(
__dirname,
require.resolve('babel-plugin-transform-react-remove-prop-types')
)
)
.ncc({ packageName: 'babel-plugin-transform-react-remove-prop-types' })
.target('compiled/babel-plugin-transform-react-remove-prop-types')
}

// eslint-disable-next-line camelcase
externals['cacache'] = 'next/dist/compiled/cacache'
export async function ncc_cacache(task, opts) {
Expand Down Expand Up @@ -335,6 +368,14 @@ export async function ncc_loader_utils(task, opts) {
.target('compiled/loader-utils')
}
// eslint-disable-next-line camelcase
externals['lodash'] = 'next/dist/compiled/lodash'
export async function ncc_lodash(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('lodash')))
.ncc({ packageName: 'lodash', externals })
.target('compiled/lodash')
}
// eslint-disable-next-line camelcase
externals['lodash.curry'] = 'next/dist/compiled/lodash.curry'
export async function ncc_lodash_curry(task, opts) {
await task
Expand Down Expand Up @@ -662,6 +703,8 @@ export async function ncc(task) {
'ncc_async_sema',
'ncc_babel_bundle',
'ncc_babel_bundle_packages',
'ncc_babel_plugin_transform_define',
'ncc_babel_plugin_transform_react_remove_prop_types',
'ncc_cacache',
'ncc_cache_loader',
'ncc_ci_info',
Expand All @@ -686,6 +729,7 @@ export async function ncc(task) {
'ncc_json5',
'ncc_jsonwebtoken',
'ncc_loader_utils',
'ncc_lodash',
'ncc_lodash_curry',
'ncc_lru_cache',
'ncc_mkdirp',
Expand Down

0 comments on commit ea2c174

Please sign in to comment.