Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix/prevent-assig…
Browse files Browse the repository at this point in the history
…nment

# Conflicts:
#	packages/replace/test/snapshots/form.js.snap
#	pnpm-lock.yaml
  • Loading branch information
shellscape committed Sep 23, 2024
2 parents 1467c25 + d823443 commit e776122
Show file tree
Hide file tree
Showing 48 changed files with 480 additions and 670 deletions.
12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
"security": "pnpm audit --audit-level=high"
},
"devDependencies": {
"@ava/babel": "2.0.0",
"@dot/versioner": "^0.3.1",
"@rollup/plugin-typescript": "^9.0.1",
"@types/conventional-commits-parser": "^3.0.2",
"@types/node": "14.18.30",
"@types/semver": "^7.3.7",
"@types/source-map-support": "^0.5.4",
"@types/yargs-parser": "^20.2.1",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"ava": "^4.3.3",
"chalk": "^4.1.0",
"codecov-lite": "2.0.0",
"conventional-commits-parser": "^3.2.1",
"del-cli": "^5.0.0",
"eslint-config-rollup": "^3.0.1",
"esm": "^3.2.25",
Expand All @@ -41,14 +36,9 @@
"nyc": "^15.1.0",
"pnpm": "^8.7.5",
"prettier-plugin-package": "^1.3.0",
"semver": "^7.3.2",
"source-map-support": "^0.5.21",
"ts-node": "10.9.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.8.3",
"write-pkg": "^4.0.0",
"yaml": "^1.10.0",
"yargs-parser": "^20.2.9"
"typescript": "^4.8.3"
},
"ava": {
"files": [
Expand Down
8 changes: 8 additions & 0 deletions packages/alias/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-alias ChangeLog

## v5.1.1

_2024-09-22_

### Bugfixes

- fix: remove unused slash dependency (#1763)

## v5.1.0

_2023-11-25_
Expand Down
5 changes: 1 addition & 4 deletions packages/alias/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-alias",
"version": "5.1.0",
"version": "5.1.1",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -58,9 +58,6 @@
"optional": true
}
},
"dependencies": {
"slash": "^4.0.0"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-typescript": "^9.0.1",
Expand Down
8 changes: 8 additions & 0 deletions packages/commonjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-commonjs ChangeLog

## v26.0.2

_2024-09-23_

### Bugfixes

- fix: replace top-level this with exports name (#1618)

## v26.0.1

_2024-06-05_
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-commonjs",
"version": "26.0.1",
"version": "26.0.2",
"publishConfig": {
"access": "public"
},
Expand Down
8 changes: 7 additions & 1 deletion packages/commonjs/src/transform-commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default async function transformCommonjs(
const topLevelAssignments = new Set();
const topLevelDefineCompiledEsmExpressions = [];
const replacedGlobal = [];
const replacedThis = [];
const replacedDynamicRequires = [];
const importedVariables = new Set();
const indentExclusionRanges = [];
Expand Down Expand Up @@ -369,7 +370,7 @@ export default async function transformCommonjs(
if (lexicalDepth === 0 && !classBodyDepth) {
uses.global = true;
if (!ignoreGlobal) {
replacedGlobal.push(node);
replacedThis.push(node);
}
}
return;
Expand Down Expand Up @@ -444,6 +445,11 @@ export default async function transformCommonjs(
storeName: true
});
}
for (const node of replacedThis) {
magicString.overwrite(node.start, node.end, exportsName, {
storeName: true
});
}
for (const node of replacedDynamicRequires) {
magicString.overwrite(
node.start,
Expand Down
5 changes: 3 additions & 2 deletions packages/commonjs/test/fixtures/function/this/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { augmentThis, classThis } = require('./foo');
const { augmentThis, classThis, y } = require('./foo');

const obj = {};
augmentThis.call(obj);

t.is(obj.x, 'x');
t.is(this.y, 'y');
t.is(this.y, undefined);
t.is(y, 'y');

const instance = new classThis();

Expand Down
9 changes: 4 additions & 5 deletions packages/commonjs/test/snapshots/function.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -7286,8 +7286,6 @@ Generated by [AVA](https://avajs.dev).
{
'main.js': `'use strict';␊
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
var main = {};␊
var foo = {};␊
Expand All @@ -7296,7 +7294,7 @@ Generated by [AVA](https://avajs.dev).
this.x = 'x';␊
};␊
commonjsGlobal.y = 'y';␊
foo.y = 'y';␊
foo.classThis = class classThis {␊
constructor(){␊
Expand All @@ -7310,13 +7308,14 @@ Generated by [AVA](https://avajs.dev).
yy = this.y␊
};␊
const { augmentThis, classThis } = foo;␊
const { augmentThis, classThis, y } = foo;␊
const obj = {};␊
augmentThis.call(obj);␊
t.is(obj.x, 'x');␊
t.is(commonjsGlobal.y, 'y');␊
t.is(main.y, undefined);␊
t.is(y, 'y');␊
const instance = new classThis();␊
Expand Down
Binary file modified packages/commonjs/test/snapshots/function.js.snap
Binary file not shown.
8 changes: 8 additions & 0 deletions packages/dynamic-import-vars/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-dynamic-import-vars ChangeLog

## v2.1.3

_2024-09-22_

### Bugfixes

- fix: simplify regex (#1751)

## v2.1.2

_2023-11-28_
Expand Down
2 changes: 1 addition & 1 deletion packages/dynamic-import-vars/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-dynamic-import-vars",
"version": "2.1.2",
"version": "2.1.3",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/dynamic-import-vars/src/dynamic-import-to-glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function dynamicImportToGlob(node, sourceString) {
}

// Disallow ./*.ext
const ownDirectoryStarExtension = /^\.\/\*\.[\w]+$/;
const ownDirectoryStarExtension = /^\.\/\*\.\w+$/;
if (ownDirectoryStarExtension.test(glob)) {
throw new VariableDynamicImportError(
`${
Expand Down
8 changes: 8 additions & 0 deletions packages/graphql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-graphql ChangeLog

## v2.0.5

_2024-09-22_

### Bugfixes

- fix: handle parentheses in fragment import file paths. (#1746)

## v2.0.4

_2023-10-05_
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-graphql",
"version": "2.0.4",
"version": "2.0.5",
"publishConfig": {
"access": "public"
},
Expand Down
10 changes: 4 additions & 6 deletions packages/graphql/src/toESModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ function replaceRequires(source) {
let index = 0;

// replace a require statement with a variable
const replaceSource = source.replace(/require\(([^)]+)\)/gi, (match, path) => {
const replacePath = path.replace(/["']+/g, '');

if (!imports[replacePath]) {
const replaceSource = source.replace(/require\(["']([^"']+)["']\)/gi, (match, path) => {
if (!imports[path]) {
index += 1;
imports[replacePath] = `frgmt${index}`;
imports[path] = `frgmt${index}`;
}

return imports[replacePath];
return imports[path];
});

// prepare import statements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fragment ParenthesesFragment on Parentheses {
id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fragment BracketsFragment on Brackets {
id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line import/prefer-default-export
export { default as doc } from './query.graphql';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import "./(parentheses)/fragment.graphql"
#import "./[brackets]/fragment.graphql"

query Query {
...ParenthesesFragment
...BracketsFragment
}
12 changes: 12 additions & 0 deletions packages/graphql/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ test('should support graphqls schema files', async (t) => {
t.truthy('doc' in module.exports);
t.is(module.exports.doc.kind, 'Document');
});

test('should support fragment imports with brackets and parentheses in file paths', async (t) => {
const bundle = await rollup({
input: 'fixtures/fragments-with-special-characters/index.js',
plugins: [graphql()]
});

const { module } = await testBundle(t, bundle);

t.truthy('doc' in module.exports);
t.is(module.exports.doc.kind, 'Document');
});
8 changes: 8 additions & 0 deletions packages/html/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-html ChangeLog

## v1.0.4

_2024-09-22_

### Bugfixes

- fix: template function first arg is always provided (#1718)

## v1.0.3

_2023-10-05_
Expand Down
2 changes: 1 addition & 1 deletion packages/html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-html",
"version": "1.0.3",
"version": "1.0.4",
"publishConfig": {
"access": "public"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/html/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface RollupHtmlOptions {
fileName?: string;
meta?: Record<string, any>[];
publicPath?: string;
template?: (templateoptions?: RollupHtmlTemplateOptions) => string;
template?: (templateoptions: RollupHtmlTemplateOptions) => string;
}

export function makeHtmlAttributes(attributes: Record<string, string>): string;
Expand Down
8 changes: 8 additions & 0 deletions packages/node-resolve/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/plugin-node-resolve ChangeLog

## v15.2.4

_2024-09-22_

### Updates

- chore: remove is-builtin-module (#1735)

## v15.2.3

_2023-10-08_
Expand Down
3 changes: 1 addition & 2 deletions packages/node-resolve/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/plugin-node-resolve",
"version": "15.2.3",
"version": "15.2.4",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -64,7 +64,6 @@
"@rollup/pluginutils": "^5.0.1",
"@types/resolve": "1.20.2",
"deepmerge": "^4.2.2",
"is-builtin-module": "^3.2.1",
"is-module": "^1.0.0",
"resolve": "^1.22.1"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-param-reassign, no-shadow, no-undefined */
import { dirname, normalize, resolve, sep } from 'path';

import isBuiltinModule from 'is-builtin-module';
import { builtinModules } from 'module';

import deepMerge from 'deepmerge';
import isModule from 'is-module';

Expand Down Expand Up @@ -42,6 +43,8 @@ const defaults = {
// TODO: set to false in next major release or remove
allowExportsFolderMapping: true
};
const nodeImportPrefix = /^node:/;

export const DEFAULTS = deepFreeze(deepMerge({}, defaults));

export function nodeResolve(opts = {}) {
Expand Down Expand Up @@ -190,7 +193,7 @@ export function nodeResolve(opts = {}) {
allowExportsFolderMapping: options.allowExportsFolderMapping
});

const importeeIsBuiltin = isBuiltinModule(importee);
const importeeIsBuiltin = builtinModules.includes(importee.replace(nodeImportPrefix, ''));
const resolved =
importeeIsBuiltin && preferBuiltins
? {
Expand Down
8 changes: 8 additions & 0 deletions packages/pluginutils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @rollup/pluginutils ChangeLog

## v5.1.1

_2024-09-22_

### Bugfixes

- fix: improve regex performance (#1753)

## v5.1.0

_2023-11-28_
Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rollup/pluginutils",
"version": "5.1.0",
"version": "5.1.1",
"publishConfig": {
"access": "public"
},
Expand Down
Loading

0 comments on commit e776122

Please sign in to comment.