@rollup/pluginutils
Advanced tools
Comparing version 4.2.1 to 5.0.0
@@ -6,8 +6,5 @@ 'use strict'; | ||
var path = require('path'); | ||
var estreeWalker = require('estree-walker'); | ||
var pm = require('picomatch'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var pm__default = /*#__PURE__*/_interopDefaultLegacy(pm); | ||
const addExtension = function addExtension(filename, ext = '.js') { | ||
@@ -20,137 +17,2 @@ let result = `${filename}`; | ||
class WalkerBase {constructor() { WalkerBase.prototype.__init.call(this);WalkerBase.prototype.__init2.call(this);WalkerBase.prototype.__init3.call(this);WalkerBase.prototype.__init4.call(this); } | ||
__init() {this.should_skip = false;} | ||
__init2() {this.should_remove = false;} | ||
__init3() {this.replacement = null;} | ||
__init4() {this.context = { | ||
skip: () => (this.should_skip = true), | ||
remove: () => (this.should_remove = true), | ||
replace: (node) => (this.replacement = node) | ||
};} | ||
replace(parent, prop, index, node) { | ||
if (parent) { | ||
if (index !== null) { | ||
parent[prop][index] = node; | ||
} else { | ||
parent[prop] = node; | ||
} | ||
} | ||
} | ||
remove(parent, prop, index) { | ||
if (parent) { | ||
if (index !== null) { | ||
parent[prop].splice(index, 1); | ||
} else { | ||
delete parent[prop]; | ||
} | ||
} | ||
} | ||
} | ||
class SyncWalkerClass extends WalkerBase { | ||
constructor(walker) { | ||
super(); | ||
this.enter = walker.enter; | ||
this.leave = walker.leave; | ||
} | ||
visit( | ||
node, | ||
parent, | ||
enter, | ||
leave, | ||
prop, | ||
index | ||
) { | ||
if (node) { | ||
if (enter) { | ||
const _should_skip = this.should_skip; | ||
const _should_remove = this.should_remove; | ||
const _replacement = this.replacement; | ||
this.should_skip = false; | ||
this.should_remove = false; | ||
this.replacement = null; | ||
enter.call(this.context, node, parent, prop, index); | ||
if (this.replacement) { | ||
node = this.replacement; | ||
this.replace(parent, prop, index, node); | ||
} | ||
if (this.should_remove) { | ||
this.remove(parent, prop, index); | ||
} | ||
const skipped = this.should_skip; | ||
const removed = this.should_remove; | ||
this.should_skip = _should_skip; | ||
this.should_remove = _should_remove; | ||
this.replacement = _replacement; | ||
if (skipped) return node; | ||
if (removed) return null; | ||
} | ||
for (const key in node) { | ||
const value = (node )[key]; | ||
if (typeof value !== "object") { | ||
continue; | ||
} else if (Array.isArray(value)) { | ||
for (let i = 0; i < value.length; i += 1) { | ||
if (value[i] !== null && typeof value[i].type === 'string') { | ||
if (!this.visit(value[i], node, enter, leave, key, i)) { | ||
// removed | ||
i--; | ||
} | ||
} | ||
} | ||
} else if (value !== null && typeof value.type === "string") { | ||
this.visit(value, node, enter, leave, key, null); | ||
} | ||
} | ||
if (leave) { | ||
const _replacement = this.replacement; | ||
const _should_remove = this.should_remove; | ||
this.replacement = null; | ||
this.should_remove = false; | ||
leave.call(this.context, node, parent, prop, index); | ||
if (this.replacement) { | ||
node = this.replacement; | ||
this.replace(parent, prop, index, node); | ||
} | ||
if (this.should_remove) { | ||
this.remove(parent, prop, index); | ||
} | ||
const removed = this.should_remove; | ||
this.replacement = _replacement; | ||
this.should_remove = _should_remove; | ||
if (removed) return null; | ||
} | ||
} | ||
return node; | ||
} | ||
} | ||
function walk(ast, walker) { | ||
const instance = new SyncWalkerClass(walker); | ||
return instance.visit(ast, null, walker.enter, walker.leave); | ||
} | ||
const extractors = { | ||
@@ -226,3 +88,3 @@ ArrayPattern(names, param) { | ||
let scope = new Scope(); | ||
walk(ast, { | ||
estreeWalker.walk(ast, { | ||
enter(n, parent) { | ||
@@ -335,3 +197,3 @@ const node = n; | ||
const pattern = getMatcherString(id, resolutionBase); | ||
const fn = pm__default["default"](pattern, { dot: true }); | ||
const fn = pm(pattern, { dot: true }); | ||
const result = fn(what); | ||
@@ -422,2 +284,3 @@ return result; | ||
const key = Symbol.keyFor(obj); | ||
// eslint-disable-next-line no-undefined | ||
if (key !== undefined) | ||
@@ -477,5 +340,7 @@ return `Symbol.for(${stringify(key)})`; | ||
exports.dataToEsm = dataToEsm; | ||
exports["default"] = index; | ||
exports.default = index; | ||
exports.extractAssignedNames = extractAssignedNames; | ||
exports.makeLegalIdentifier = makeLegalIdentifier; | ||
exports.normalizePath = normalizePath; | ||
module.exports = Object.assign(exports.default, exports); | ||
//# sourceMappingURL=index.js.map |
import { extname, win32, posix, isAbsolute, resolve } from 'path'; | ||
import { walk } from 'estree-walker'; | ||
import pm from 'picomatch'; | ||
@@ -11,137 +12,2 @@ | ||
class WalkerBase {constructor() { WalkerBase.prototype.__init.call(this);WalkerBase.prototype.__init2.call(this);WalkerBase.prototype.__init3.call(this);WalkerBase.prototype.__init4.call(this); } | ||
__init() {this.should_skip = false;} | ||
__init2() {this.should_remove = false;} | ||
__init3() {this.replacement = null;} | ||
__init4() {this.context = { | ||
skip: () => (this.should_skip = true), | ||
remove: () => (this.should_remove = true), | ||
replace: (node) => (this.replacement = node) | ||
};} | ||
replace(parent, prop, index, node) { | ||
if (parent) { | ||
if (index !== null) { | ||
parent[prop][index] = node; | ||
} else { | ||
parent[prop] = node; | ||
} | ||
} | ||
} | ||
remove(parent, prop, index) { | ||
if (parent) { | ||
if (index !== null) { | ||
parent[prop].splice(index, 1); | ||
} else { | ||
delete parent[prop]; | ||
} | ||
} | ||
} | ||
} | ||
class SyncWalkerClass extends WalkerBase { | ||
constructor(walker) { | ||
super(); | ||
this.enter = walker.enter; | ||
this.leave = walker.leave; | ||
} | ||
visit( | ||
node, | ||
parent, | ||
enter, | ||
leave, | ||
prop, | ||
index | ||
) { | ||
if (node) { | ||
if (enter) { | ||
const _should_skip = this.should_skip; | ||
const _should_remove = this.should_remove; | ||
const _replacement = this.replacement; | ||
this.should_skip = false; | ||
this.should_remove = false; | ||
this.replacement = null; | ||
enter.call(this.context, node, parent, prop, index); | ||
if (this.replacement) { | ||
node = this.replacement; | ||
this.replace(parent, prop, index, node); | ||
} | ||
if (this.should_remove) { | ||
this.remove(parent, prop, index); | ||
} | ||
const skipped = this.should_skip; | ||
const removed = this.should_remove; | ||
this.should_skip = _should_skip; | ||
this.should_remove = _should_remove; | ||
this.replacement = _replacement; | ||
if (skipped) return node; | ||
if (removed) return null; | ||
} | ||
for (const key in node) { | ||
const value = (node )[key]; | ||
if (typeof value !== "object") { | ||
continue; | ||
} else if (Array.isArray(value)) { | ||
for (let i = 0; i < value.length; i += 1) { | ||
if (value[i] !== null && typeof value[i].type === 'string') { | ||
if (!this.visit(value[i], node, enter, leave, key, i)) { | ||
// removed | ||
i--; | ||
} | ||
} | ||
} | ||
} else if (value !== null && typeof value.type === "string") { | ||
this.visit(value, node, enter, leave, key, null); | ||
} | ||
} | ||
if (leave) { | ||
const _replacement = this.replacement; | ||
const _should_remove = this.should_remove; | ||
this.replacement = null; | ||
this.should_remove = false; | ||
leave.call(this.context, node, parent, prop, index); | ||
if (this.replacement) { | ||
node = this.replacement; | ||
this.replace(parent, prop, index, node); | ||
} | ||
if (this.should_remove) { | ||
this.remove(parent, prop, index); | ||
} | ||
const removed = this.should_remove; | ||
this.replacement = _replacement; | ||
this.should_remove = _should_remove; | ||
if (removed) return null; | ||
} | ||
} | ||
return node; | ||
} | ||
} | ||
function walk(ast, walker) { | ||
const instance = new SyncWalkerClass(walker); | ||
return instance.visit(ast, null, walker.enter, walker.leave); | ||
} | ||
const extractors = { | ||
@@ -411,2 +277,3 @@ ArrayPattern(names, param) { | ||
const key = Symbol.keyFor(obj); | ||
// eslint-disable-next-line no-undefined | ||
if (key !== undefined) | ||
@@ -463,1 +330,2 @@ return `Symbol.for(${stringify(key)})`; | ||
export { addExtension, attachScopes, createFilter, dataToEsm, index as default, extractAssignedNames, makeLegalIdentifier, normalizePath }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@rollup/pluginutils", | ||
"version": "4.2.1", | ||
"version": "5.0.0", | ||
"publishConfig": { | ||
@@ -22,7 +22,8 @@ "access": "public" | ||
"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" | ||
}, | ||
@@ -38,4 +39,4 @@ "scripts": { | ||
"prerelease": "pnpm build", | ||
"pretest": "pnpm build -- --sourcemap", | ||
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name", | ||
"pretest": "pnpm build --sourcemap", | ||
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name", | ||
"test": "ava", | ||
@@ -46,2 +47,3 @@ "test:ts": "tsc --noEmit" | ||
"dist", | ||
"!dist/**/*.map", | ||
"types", | ||
@@ -56,22 +58,27 @@ "README.md", | ||
], | ||
"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": { | ||
"babel": { | ||
"compileEnhancements": false | ||
}, | ||
"extensions": [ | ||
@@ -83,2 +90,3 @@ "ts" | ||
], | ||
"workerThreads": false, | ||
"files": [ | ||
@@ -85,0 +93,0 @@ "!**/fixtures/**", |
@@ -16,3 +16,3 @@ [npm]: https://img.shields.io/npm/v/@rollup/pluginutils | ||
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+. | ||
@@ -19,0 +19,0 @@ ## Install |
@@ -1,2 +0,1 @@ | ||
// eslint-disable-next-line import/no-unresolved | ||
import { BaseNode } from 'estree'; | ||
@@ -3,0 +2,0 @@ |
37726
3
6
730
+ Addedfsevents@2.3.3(transitive)
+ Addedrollup@3.29.4(transitive)
Updatedestree-walker@^2.0.2
Updatedpicomatch@^2.3.1