Skip to content

Commit

Permalink
Merge branch 'master' into feat/keep-extension-for-amd
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Aug 31, 2022
2 parents 4427349 + eb1fab7 commit 22a6dfb
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
@@ -1,5 +1,17 @@
# rollup changelog

## 2.78.1

_2022-08-19_

### Bug Fixes

- Avoid inferring "arguments" as name for a default export placeholder variable (#4613)

### Pull Requests

- [#4613](https://github.com/rollup/rollup/pull/4613): Prevent using arguments for generated variable names (@lukastaegert)

## 2.78.0

_2022-08-14_
Expand All @@ -12,7 +24,7 @@ _2022-08-14_

### Pull Requests

- [#4600](https://github.com/rollup/rollup/pull/4591): Allow using objects as hooks to change execution order (@lukastaegert)
- [#4600](https://github.com/rollup/rollup/pull/4600): Allow using objects as hooks to change execution order (@lukastaegert)

## 2.77.3

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "2.78.0",
"version": "2.78.1",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/es/rollup.js",
Expand Down
7 changes: 5 additions & 2 deletions src/utils/identifierHelpers.ts
Expand Up @@ -4,8 +4,11 @@ const illegalCharacters = /[^$_a-zA-Z0-9]/g;

const startsWithDigit = (str: string): boolean => /\d/.test(str[0]);

const needsEscape = (str: string) =>
startsWithDigit(str) || RESERVED_NAMES.has(str) || str === 'arguments';

export function isLegal(str: string): boolean {
if (startsWithDigit(str) || RESERVED_NAMES.has(str)) {
if (needsEscape(str)) {
return false;
}
return !illegalCharacters.test(str);
Expand All @@ -14,7 +17,7 @@ export function isLegal(str: string): boolean {
export function makeLegal(str: string): string {
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');

if (startsWithDigit(str) || RESERVED_NAMES.has(str)) str = `_${str}`;
if (needsEscape(str)) str = `_${str}`;

return str || '_';
}
2 changes: 1 addition & 1 deletion test/form/samples/quote-id/_config.js
Expand Up @@ -9,7 +9,7 @@ module.exports = {
options: {
output: {
paths: id => {
if (id.startsWith('C:')) return id;
if (id === external3) return id;
return path.relative(__dirname, id);
},
name: 'Q',
Expand Down
8 changes: 8 additions & 0 deletions test/function/samples/escape-arguments/_config.js
@@ -0,0 +1,8 @@
const assert = require('assert');

module.exports = {
description: 'does not use "arguments" as a placeholder variable for a default export',
exports(exports) {
assert.deepStrictEqual(exports, { foo: { __proto__: null, default: 42 } });
}
};
1 change: 1 addition & 0 deletions test/function/samples/escape-arguments/arguments.js
@@ -0,0 +1 @@
export default 42;
1 change: 1 addition & 0 deletions test/function/samples/escape-arguments/main.js
@@ -0,0 +1 @@
export * as foo from './arguments.js';

0 comments on commit 22a6dfb

Please sign in to comment.