Skip to content

Commit e2d74c0

Browse files
committed
Merge branch 'master' into commonjs-strict-requires-true
2 parents 3d78403 + 28b9701 commit e2d74c0

File tree

89 files changed

+1206
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1206
-447
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ packages/typescript/test/fixtures/syntax-error
77

88
# temporary workaround for eslint bug where package.json is a directory
99
packages/node-resolve/test/fixtures/package-json-in-path
10+
11+
# temporary workaround for TypeScript as it doesn't support "Arbitrary module namespace identifier names"
12+
# https://github.com/microsoft/TypeScript/issues/40594
13+
packages/json/test/fixtures/arbitrary/main.js

.husky/pre-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
pnpm dlx lint-staged
4+
pnpm exec lint-staged

package.json

+4-13
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,23 @@
99
"lint:js": "eslint --cache packages scripts shared util --ext .js,.ts,.mjs",
1010
"lint:json": "prettier --write .github/**/*.yml **/tsconfig.json tsconfig.*.json pnpm-workspace.yaml",
1111
"lint:package": "prettier --write **/package.json",
12-
"package:release": "versioner --stripShortName='^@.+/plugin-' --target",
12+
"package:release": "versioner --stripShortName='^@.+/(plugin-)?' --target",
1313
"preinstall": "node scripts/disallow-npm.js",
1414
"prepare": "husky install",
1515
"prettier": "prettier --write .",
1616
"prettier:check": "prettier --check .",
1717
"security": "pnpm audit --audit-level=high"
1818
},
1919
"devDependencies": {
20-
"@ava/babel": "2.0.0",
2120
"@dot/versioner": "^0.3.1",
2221
"@rollup/plugin-typescript": "^9.0.1",
23-
"@types/conventional-commits-parser": "^3.0.2",
2422
"@types/node": "14.18.30",
25-
"@types/semver": "^7.3.7",
2623
"@types/source-map-support": "^0.5.4",
27-
"@types/yargs-parser": "^20.2.1",
2824
"@typescript-eslint/eslint-plugin": "^5.38.0",
2925
"@typescript-eslint/parser": "^5.38.0",
3026
"ava": "^4.3.3",
3127
"chalk": "^4.1.0",
3228
"codecov-lite": "2.0.0",
33-
"conventional-commits-parser": "^3.2.1",
3429
"del-cli": "^5.0.0",
3530
"eslint-config-rollup": "^3.0.1",
3631
"esm": "^3.2.25",
@@ -41,14 +36,9 @@
4136
"nyc": "^15.1.0",
4237
"pnpm": "^8.7.5",
4338
"prettier-plugin-package": "^1.3.0",
44-
"semver": "^7.3.2",
4539
"source-map-support": "^0.5.21",
4640
"ts-node": "10.9.1",
47-
"tsconfig-paths": "^3.9.0",
48-
"typescript": "^4.8.3",
49-
"write-pkg": "^4.0.0",
50-
"yaml": "^1.10.0",
51-
"yargs-parser": "^20.2.9"
41+
"typescript": "^4.8.3"
5242
},
5343
"ava": {
5444
"files": [
@@ -85,5 +75,6 @@
8575
"lib/client*.js",
8676
"test/"
8777
]
88-
}
78+
},
79+
"packageManager": "pnpm@8.15.8+sha512.d1a029e1a447ad90bc96cd58b0fad486d2993d531856396f7babf2d83eb1823bb83c5a3d0fc18f675b2d10321d49eb161fece36fe8134aa5823ecd215feed392"
8980
}

packages/alias/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @rollup/plugin-alias ChangeLog
22

3+
## v5.1.1
4+
5+
_2024-09-22_
6+
7+
### Bugfixes
8+
9+
- fix: remove unused slash dependency (#1763)
10+
311
## v5.1.0
412

513
_2023-11-25_

packages/alias/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rollup/plugin-alias",
3-
"version": "5.1.0",
3+
"version": "5.1.1",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -58,9 +58,6 @@
5858
"optional": true
5959
}
6060
},
61-
"dependencies": {
62-
"slash": "^4.0.0"
63-
},
6461
"devDependencies": {
6562
"@rollup/plugin-node-resolve": "^15.0.0",
6663
"@rollup/plugin-typescript": "^9.0.1",

packages/commonjs/CHANGELOG.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# @rollup/plugin-commonjs ChangeLog
22

3+
## v26.0.1
4+
5+
_2024-06-05_
6+
7+
### Bugfixes
8+
9+
- fix: correct import of glob (04a15b5)
10+
11+
## v26.0.0
12+
13+
_2024-06-05_
14+
15+
### Breaking Changes
16+
17+
- chore!: bump glob's version (#1695)
18+
19+
## v25.0.8
20+
21+
_2024-05-22_
22+
23+
### Bugfixes
24+
25+
- fix: preserve the class body property keys even if they are special keywords (#1688)
26+
327
## v25.0.7
428

529
_2023-10-15_

packages/commonjs/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rollup/plugin-commonjs",
3-
"version": "25.0.7",
3+
"version": "26.0.1",
44
"publishConfig": {
55
"access": "public"
66
},
@@ -21,7 +21,7 @@
2121
"default": "./dist/cjs/index.js"
2222
},
2323
"engines": {
24-
"node": ">=14.0.0"
24+
"node": ">=16.0.0 || 14 >= 14.17"
2525
},
2626
"scripts": {
2727
"build": "rollup -c",
@@ -65,7 +65,7 @@
6565
"@rollup/pluginutils": "^5.0.1",
6666
"commondir": "^1.0.1",
6767
"estree-walker": "^2.0.2",
68-
"glob": "^8.0.3",
68+
"glob": "^10.4.1",
6969
"is-reference": "1.2.1",
7070
"magic-string": "^0.30.3"
7171
},
@@ -75,7 +75,6 @@
7575
"locate-character": "^2.0.5",
7676
"require-relative": "^0.8.7",
7777
"rollup": "^4.0.0-24",
78-
"shx": "^0.3.4",
7978
"source-map": "^0.7.4",
8079
"source-map-support": "^0.5.21",
8180
"typescript": "^4.8.3"

packages/commonjs/src/dynamic-modules.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { join, resolve, dirname } from 'path';
33

44
import getCommonDir from 'commondir';
55

6-
import glob from 'glob';
6+
import { glob } from 'glob';
77

88
import { getVirtualPathForDynamicRequirePath, normalizePathSlashes } from './utils';
99

@@ -41,7 +41,9 @@ export function getDynamicRequireModules(patterns, dynamicRequireRoot) {
4141
isNegated
4242
? dynamicRequireModules.delete(targetPath)
4343
: dynamicRequireModules.set(targetPath, resolvedPath);
44-
for (const path of glob.sync(isNegated ? pattern.substr(1) : pattern)) {
44+
for (const path of glob
45+
.sync(isNegated ? pattern.substr(1) : pattern)
46+
.sort((a, b) => a.localeCompare(b, 'en'))) {
4547
const resolvedPath = resolve(path);
4648
const requirePath = normalizePathSlashes(resolvedPath);
4749
if (isDirectory(resolvedPath)) {

packages/commonjs/src/transform-commonjs.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,12 @@ export default async function transformCommonjs(
291291
return;
292292
case 'Identifier': {
293293
const { name } = node;
294-
if (!isReference(node, parent) || scope.contains(name)) return;
294+
if (
295+
!isReference(node, parent) ||
296+
scope.contains(name) ||
297+
(parent.type === 'PropertyDefinition' && parent.key === node)
298+
)
299+
return;
295300
switch (name) {
296301
case 'require':
297302
uses.require = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
description: 'preserve the class body property keys even if they are special keywords',
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Rollup {
2+
define;
3+
require;
4+
global;
5+
}
6+
7+
exports.Rollup = Rollup;

packages/commonjs/test/snapshots/function.js.md

+35
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,41 @@ Generated by [AVA](https://avajs.dev).
367367
`,
368368
}
369369

370+
## class-body-property-keys-are-special-keywords
371+
372+
> Snapshot 1
373+
374+
{
375+
'main.js': `'use strict';␊
376+
377+
function getDefaultExportFromCjs (x) {␊
378+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
379+
}␊
380+
381+
var main$1 = {};␊
382+
383+
var hasRequiredMain;␊
384+
385+
function requireMain () {␊
386+
if (hasRequiredMain) return main$1;␊
387+
hasRequiredMain = 1;␊
388+
class Rollup {␊
389+
define;␊
390+
require;␊
391+
global;␊
392+
}␊
393+
394+
main$1.Rollup = Rollup;␊
395+
return main$1;␊
396+
}␊
397+
398+
var mainExports = requireMain();␊
399+
var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports);␊
400+
401+
module.exports = main;␊
402+
`,
403+
}
404+
370405
## compiled-esm-default-is-module-exports-false
371406

372407
> Snapshot 1
153 Bytes
Binary file not shown.

packages/dynamic-import-vars/CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# @rollup/plugin-dynamic-import-vars ChangeLog
22

3+
## v2.1.3
4+
5+
_2024-09-22_
6+
7+
### Bugfixes
8+
9+
- fix: simplify regex (#1751)
10+
11+
## v2.1.2
12+
13+
_2023-11-28_
14+
15+
### Bugfixes
16+
17+
- fix: Allow a "no files found" error to be emitted as warning (#1625)
18+
319
## v2.1.1
420

521
_2023-11-25_

packages/dynamic-import-vars/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Default: `false`
6868

6969
By default, the plugin will not throw errors when target files are not found. Setting this option to true will result in errors thrown when encountering files which don't exist.
7070

71+
⚠️ _Important:_ Enabling this option when `warnOnError` is set to `true` will result in a warning and _not_ an error
72+
7173
#### `warnOnError`
7274

7375
Type: `Boolean`<br>

packages/dynamic-import-vars/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rollup/plugin-dynamic-import-vars",
3-
"version": "2.1.1",
3+
"version": "2.1.3",
44
"publishConfig": {
55
"access": "public"
66
},

packages/dynamic-import-vars/src/dynamic-import-to-glob.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function dynamicImportToGlob(node, sourceString) {
107107
}
108108

109109
// Disallow ./*.ext
110-
const ownDirectoryStarExtension = /^\.\/\*\.[\w]+$/;
110+
const ownDirectoryStarExtension = /^\.\/\*\.\w+$/;
111111
if (ownDirectoryStarExtension.test(glob)) {
112112
throw new VariableDynamicImportError(
113113
`${

packages/dynamic-import-vars/src/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFile
5656
);
5757

5858
if (errorWhenNoFilesFound && paths.length === 0) {
59-
this.error(
60-
new Error(
61-
`No files found in ${glob} when trying to dynamically load concatted string from ${id}`
62-
)
59+
const error = new Error(
60+
`No files found in ${glob} when trying to dynamically load concatted string from ${id}`
6361
);
62+
if (warnOnError) {
63+
this.warn(error);
64+
} else {
65+
this.error(error);
66+
}
6467
}
6568

6669
// create magic string if it wasn't created already

packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ test("doesn't throw if no files in dir when option isn't set", async (t) => {
218218
t.false(thrown);
219219
});
220220

221-
test('throws if no files in dir when option is set', async (t) => {
221+
test('throws if no files in dir when `errorWhenNoFilesFound` is set', async (t) => {
222222
let thrown = false;
223223
try {
224224
await rollup({
@@ -236,3 +236,21 @@ test('throws if no files in dir when option is set', async (t) => {
236236
}
237237
t.true(thrown);
238238
});
239+
240+
test('warns if no files in dir when `errorWhenNoFilesFound` and `warnOnError` are both set', async (t) => {
241+
let warningEmitted = false;
242+
await rollup({
243+
input: 'fixture-no-files.js',
244+
plugins: [dynamicImportVars({ errorWhenNoFilesFound: true, warnOnError: true })],
245+
onwarn(warning) {
246+
t.deepEqual(
247+
warning.message,
248+
`No files found in ./module-dir-c/*.js when trying to dynamically load concatted string from ${require.resolve(
249+
'./fixtures/fixture-no-files.js'
250+
)}`
251+
);
252+
warningEmitted = true;
253+
}
254+
});
255+
t.true(warningEmitted);
256+
});

packages/esm-shim/CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# @rollup/plugin-esm-shim ChangeLog
22

3+
## v0.1.7
4+
5+
_2024-06-05_
6+
7+
### Bugfixes
8+
9+
- fix: missing exports in types (#1670)
10+
11+
## v0.1.6
12+
13+
_2024-04-05_
14+
15+
### Bugfixes
16+
17+
- fix: do not insert shims at `import` literal (#1696)
18+
319
## v0.1.5
420

521
_2023-11-05_

packages/esm-shim/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rollup/plugin-esm-shim",
3-
"version": "0.1.5",
3+
"version": "0.1.7",
44
"publishConfig": {
55
"access": "public"
66
},

packages/esm-shim/src/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ const require = cjsModule.createRequire(import.meta.url);
1111
`;
1212

1313
export const ESMStaticImportRegex =
14-
/(?<=\s|^|;)import\s*([\s"']*(?<imports>[\w\t\n\r $*,/{}]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gm;
14+
/(?<=\s|^|;)import\s*([\s"']*(?<imports>[\w\t\n\r $*,/{}]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"\n]*[^\s"](?=\s*")|(?<='\s*)[^'\n]*[^\s'](?=\s*'))\s*["'][\s;]*/gm;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const dn = __dirname;
2+
3+
module.exports = {
4+
keyword: ' import',
5+
dn
6+
};

0 commit comments

Comments
 (0)