Skip to content

Commit

Permalink
fix(pluginutils): prepare for Rollup 3
Browse files Browse the repository at this point in the history
BREAKING CHANGES: Requires Node 14
  • Loading branch information
lukastaegert committed Oct 10, 2022
1 parent 6bd4ce7 commit 7f12cb1
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 71 deletions.
2 changes: 1 addition & 1 deletion packages/pluginutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A set of utility functions commonly used by 🍣 Rollup plugins.

## Requirements

This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
The plugin utils require an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.

## Install

Expand Down
40 changes: 25 additions & 15 deletions packages/pluginutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"module": "./dist/es/index.js",
"type": "commonjs",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
"types": "./types/index.d.ts",
"import": "./dist/es/index.js",
"default": "./dist/cjs/index.js"
},
"engines": {
"node": ">= 8.0.0"
"node": ">=14.0.0"
},
"scripts": {
"build": "rollup -c",
Expand All @@ -41,6 +42,7 @@
},
"files": [
"dist",
"!dist/**/*.map",
"types",
"README.md",
"LICENSE"
Expand All @@ -50,22 +52,30 @@
"plugin",
"utils"
],
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0||^3.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
},
"dependencies": {
"estree-walker": "^2.0.1",
"picomatch": "^2.2.2"
"estree-walker": "^2.0.2",
"picomatch": "^2.3.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-typescript": "^5.0.2",
"@types/estree": "0.0.45",
"@types/node": "^14.0.26",
"@types/picomatch": "^2.2.1",
"acorn": "^8.0.4",
"rollup": "^2.67.3",
"typescript": "^4.1.2"
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^14.1.0",
"@rollup/plugin-typescript": "^8.5.0",
"@types/estree": "1.0.0",
"@types/node": "^14.18.30",
"@types/picomatch": "^2.3.0",
"acorn": "^8.8.0",
"rollup": "^3.0.0-7",
"typescript": "^4.8.3"
},
"types": "types/index.d.ts",
"types": "./types/index.d.ts",
"ava": {
"extensions": [
"ts"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { builtinModules } from 'module';
import { readFileSync } from 'fs';

import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';

import { emitModulePackageFile } from '../../shared/rollup.config';

import pkg from './package.json';
import { createConfig } from '../../shared/rollup.config.mjs';

export default {
...createConfig({
pkg: JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
}),
input: 'src/index.ts',
plugins: [
resolve(),
commonjs({ include: '../../node_modules/.pnpm/registry.npmjs.org/**' }),
typescript({ include: '**/*.{ts,js}', module: 'esnext' })
],
external: [...builtinModules, 'picomatch'],
output: [
{ file: pkg.main, format: 'cjs', exports: 'named' },
{ file: pkg.module, format: 'es', plugins: [emitModulePackageFile()] }
]
};
2 changes: 1 addition & 1 deletion packages/pluginutils/src/addExtension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { extname } from 'path';

import { AddExtension } from '../types';
import type { AddExtension } from '../types';

const addExtension: AddExtension = function addExtension(filename, ext = '.js') {
let result = `${filename}`;
Expand Down
3 changes: 1 addition & 2 deletions packages/pluginutils/src/attachScopes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// eslint-disable-next-line import/no-unresolved
import * as estree from 'estree';

import { walk } from 'estree-walker';

import { AttachedScope, AttachScopes } from '../types';
import type { AttachedScope, AttachScopes } from '../types';

import extractAssignedNames from './extractAssignedNames';

Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/src/createFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { resolve, posix, isAbsolute } from 'path';

import pm from 'picomatch';

import { CreateFilter } from '../types';
import type { CreateFilter } from '../types';

import ensureArray from './utils/ensureArray';
import normalizePath from './normalizePath';
Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/src/dataToEsm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataToEsm } from '../types';
import type { DataToEsm } from '../types';

import makeLegalIdentifier from './makeLegalIdentifier';

Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/src/extractAssignedNames.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtractAssignedNames } from '../types';
import type { ExtractAssignedNames } from '../types';

interface Extractors {
[key: string]: (names: string[], param: any) => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/src/makeLegalIdentifier.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MakeLegalIdentifier } from '../types';
import type { MakeLegalIdentifier } from '../types';

const reservedWords =
'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/src/normalizePath.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { win32, posix } from 'path';

import { NormalizePath } from '../types';
import type { NormalizePath } from '../types';

const normalizePath: NormalizePath = function normalizePath(filename: string) {
return filename.split(win32.sep).join(posix.sep);
Expand Down
1 change: 0 additions & 1 deletion packages/pluginutils/test/attachScopes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-unresolved
import * as estree from 'estree';

import test from 'ava';
Expand Down
1 change: 0 additions & 1 deletion packages/pluginutils/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-unresolved
import { BaseNode } from 'estree';

export interface AttachedScope {
Expand Down
52 changes: 16 additions & 36 deletions pnpm-lock.yaml

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

0 comments on commit 7f12cb1

Please sign in to comment.