Skip to content

Commit

Permalink
Update rollup packages (#14003)
Browse files Browse the repository at this point in the history
* Update Rollup to `^2.60.1` (it generates an invalid bundle)

* Update `@rollup/plugin-commonjs`

* `@rollup/plugin-commonjs@22.0.0-0`

* Update other @rollup/ packages

* Replace `rollup-plugin-node-polyfills` with maintained fork

* update rollup plugins

* update rollup to 2.63.0

* remove dynamic require entrypoint

* Update

* Update rollup packages

* Revert #14462 (Rolluo always normalizes paths now)

* Update `rollup-plugin-polyfill-node`

* Avoid `require` to files external to the bundle

https://github.com/rollup/plugins/tree/master/packages/commonjs#ignoredynamicrequires=

* Update `rollup-plugin-dts`

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
  • Loading branch information
nicolo-ribaudo and JLHwung committed Apr 24, 2022
1 parent bdc4eb5 commit 0d2ae01
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 148 deletions.
28 changes: 0 additions & 28 deletions .yarn/patches/@rollup__plugin-commonjs.patch

This file was deleted.

18 changes: 6 additions & 12 deletions Gulpfile.mjs
Expand Up @@ -12,12 +12,11 @@ import { rollup } from "rollup";
import { babel as rollupBabel } from "@rollup/plugin-babel";
import rollupCommonJs from "@rollup/plugin-commonjs";
import rollupJson from "@rollup/plugin-json";
import rollupNodePolyfills from "rollup-plugin-node-polyfills";
import rollupPolyfillNode from "rollup-plugin-polyfill-node";
import rollupNodeResolve from "@rollup/plugin-node-resolve";
import rollupReplace from "@rollup/plugin-replace";
import { terser as rollupTerser } from "rollup-plugin-terser";
import _rollupDts from "rollup-plugin-dts";
const { default: rollupDts } = _rollupDts;
import rollupDts from "rollup-plugin-dts";
import { Worker as JestWorker } from "jest-worker";
import glob from "glob";
import { resolve as importMetaResolve } from "import-meta-resolve";
Expand Down Expand Up @@ -297,8 +296,6 @@ function buildRollup(packages, targetBrowsers) {
input,
external,
onwarn(warning, warn) {
const osifyPath = str => str.split("/").join(path.sep);

if (warning.code === "CIRCULAR_DEPENDENCY") return;
if (warning.code === "UNUSED_EXTERNAL_IMPORT") {
warn(warning);
Expand All @@ -310,15 +307,14 @@ function buildRollup(packages, targetBrowsers) {
// We can safely ignore this warning, and let Rollup replace it with undefined.
if (
warning.code === "MISSING_EXPORT" &&
warning.exporter ===
osifyPath("packages/babel-core/src/index.ts") &&
warning.exporter === "packages/babel-core/src/index.ts" &&
warning.missing === "default" &&
[
"@babel/helper-define-polyfill-provider",
"babel-plugin-polyfill-corejs2",
"babel-plugin-polyfill-corejs3",
"babel-plugin-polyfill-regenerator",
].some(pkg => warning.importer.includes(osifyPath(pkg)))
].some(pkg => warning.importer.includes(pkg))
) {
return;
}
Expand Down Expand Up @@ -348,8 +344,6 @@ function buildRollup(packages, targetBrowsers) {
// Rollup doesn't read export maps, so it loads the cjs fallback
"packages/babel-compat-data/*.js",
"packages/*/src/**/*.cjs",
// See the comment in this file for the reason to include it
"packages/babel-standalone/src/dynamic-require-entrypoint.cjs",
],
dynamicRequireTargets: [
// https://github.com/mathiasbynens/regexpu-core/blob/ffd8fff2e31f4597f6fdfee75d5ac1c5c8111ec3/rewrite-pattern.js#L48
Expand All @@ -361,7 +355,7 @@ function buildRollup(packages, targetBrowsers) {
) + "/**/*.js",
],
// Never delegate to the native require()
ignoreDynamicRequires: true,
ignoreDynamicRequires: false,
// Align with the Node.js behavior
defaultIsModuleExports: true,
}),
Expand All @@ -382,7 +376,7 @@ function buildRollup(packages, targetBrowsers) {
}),
rollupJson(),
targetBrowsers &&
rollupNodePolyfills({
rollupPolyfillNode({
sourceMap: sourcemap,
include: "**/*.{js,cjs,ts}",
}),
Expand Down
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -34,11 +34,11 @@
"@babel/preset-flow": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@babel/runtime": "^7.17.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "patch:@rollup/plugin-commonjs@^18.1.0#./.yarn/patches/@rollup__plugin-commonjs.patch",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-node-resolve": "^13.2.1",
"@rollup/plugin-replace": "^4.0.0",
"@types/node": "^16.7.13",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
Expand Down Expand Up @@ -67,9 +67,9 @@
"lint-staged": "^9.2.0",
"mergeiterator": "^1.4.4",
"prettier": "2.5.0",
"rollup": "~2.54.0",
"rollup-plugin-dts": "^2.0.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup": "^2.70.2",
"rollup-plugin-dts": "^4.2.1",
"rollup-plugin-polyfill-node": "^0.9.0",
"rollup-plugin-terser": "^7.0.2",
"semver": "^6.3.0",
"test262-stream": "^1.4.0",
Expand Down
13 changes: 0 additions & 13 deletions packages/babel-standalone/src/dynamic-require-entrypoint.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions packages/babel-standalone/src/index.ts
Expand Up @@ -11,9 +11,6 @@
/* eslint-disable max-len */
/// <reference lib="dom" />

// $FlowIgnore
import "./dynamic-require-entrypoint.cjs";

import {
transformFromAst as babelTransformFromAst,
transform as babelTransform,
Expand Down
6 changes: 3 additions & 3 deletions test/runtime-integration/rollup/package.json
Expand Up @@ -3,8 +3,8 @@
"private": true,
"devDependencies": {
"@babel/runtime": "workspace:^",
"@rollup/plugin-commonjs": "^18.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"rollup": "~2.54.0"
"@rollup/plugin-commonjs": "22.0.0",
"@rollup/plugin-node-resolve": "^13.2.1",
"rollup": "^2.70.2"
}
}

0 comments on commit 0d2ae01

Please sign in to comment.