Skip to content

Commit

Permalink
Ensure @babel/core is not duplicated (#28716)
Browse files Browse the repository at this point in the history
Follow-up to #28713 this ensures we also don't duplicate `@babel/core` in our `babel-packages` bundle. This was occurring from us re-using the `@babel/core` package name which causes us to remove it from the externals [here](https://github.com/vercel/next.js/blob/77c0e0937128409960ee48ee965501f4d18c9c82/packages/next/taskfile-ncc.js#L18-L21).
  • Loading branch information
ijjk committed Sep 1, 2021
1 parent 77c0e09 commit 2d1cb8f
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 11,660 deletions.
22 changes: 0 additions & 22 deletions packages/next/compiled/babel-packages/LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion packages/next/compiled/babel-packages/package.json
@@ -1 +1 @@
{"name":"@babel/core","main":"packages-bundle.js","author":"The Babel Team (https://babel.dev/team)","license":"MIT"}
{"name":"babel-packages","main":"./packages-bundle.js"}
11,993 changes: 359 additions & 11,634 deletions packages/next/compiled/babel-packages/packages-bundle.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions packages/next/taskfile.js
@@ -1,8 +1,9 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const notifier = require('node-notifier')
// eslint-disable-next-line import/no-extraneous-dependencies
const { relative, basename, resolve } = require('path')
const { relative, basename, resolve, join } = require('path')
const { Module } = require('module')
const fs = require('fs')

// Note:
// "bundles" folder shadows main node_modules in workspace where all installs in
Expand Down Expand Up @@ -155,12 +156,15 @@ export async function ncc_babel_bundle_packages(task, opts) {
await task
.source(opts.src || 'bundles/babel/packages-bundle.js')
.ncc({
packageName: `@babel/core`,
bundleName: 'babel-packages',
externals: externals,
})
.target(`compiled/babel-packages`)

await fs.promises.writeFile(
join(__dirname, 'compiled/babel-packages/package.json'),
JSON.stringify({ name: 'babel-packages', main: './packages-bundle.js' })
)

await task
.source(opts.src || 'bundles/babel/packages/*')
.target('compiled/babel')
Expand Down

0 comments on commit 2d1cb8f

Please sign in to comment.