From 802ba2c5d0e011e98503245c6010b4a8b8197965 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Mon, 17 Aug 2020 13:53:22 -0700 Subject: [PATCH 1/2] Migrate to ESM We've recently migrated Chrome DevTools to ESM, and have traditionally been using acorn as the parser for various features including the prettifier. In the context of https://crbug.com/1084349 we are looking into including private fields support in Chrome DevTools via this plugin, and in order to make that easier with our build system, I've added support for ESM output here in addition to the CJS output. Similar change to https://github.com/acornjs/acorn-private-methods/pull/4. --- .gitignore | 1 + index.js | 4 ++-- package.json | 8 ++++++-- rollup.config.js | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 rollup.config.js diff --git a/.gitignore b/.gitignore index c2658d7..1eae0cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +dist/ node_modules/ diff --git a/index.js b/index.js index 7511a64..582deb8 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -"use strict" +"use strict"; const getPrototype = Object.getPrototypeOf || (o => o.__proto__) @@ -21,7 +21,7 @@ const getAcorn = Parser => { return acorn } -module.exports = function(Parser) { +export default function privateClassElements(Parser) { // Only load this plugin once. if (Parser.prototype.parsePrivateName) { return Parser diff --git a/package.json b/package.json index d17c20b..61cfe81 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "contributors": [ "Adrian Heine " ], + "main": "dist/acorn-private-class-elements.js", + "module": "dist/acorn-private-class-elements.mjs", "engines": { "node": ">=4.8.2" }, @@ -14,17 +16,19 @@ }, "license": "MIT", "scripts": { + "build": "rollup -c rollup.config.js", "test": "mocha", "lint": "eslint -c .eslintrc.json ." }, "peerDependencies": { "acorn": "^6.1.0 || ^7 || ^8" }, - "version": "0.2.7", + "version": "0.2.8", "devDependencies": { "acorn": "^7.0.0", "eslint": "^7", "eslint-plugin-node": "^11.0.0", - "mocha": "^8" + "mocha": "^8", + "rollup": "^2.10.0" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..6cee364 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,15 @@ +export default { + input: "index.js", + output: [ + { + file: "dist/acorn-private-class-elements.js", + format: "cjs", + sourcemap: true + }, + { + file: "dist/acorn-private-class-elements.mjs", + format: "es", + sourcemap: true + } + ] +} From fe106602a03e9dbda5411c9219b5545621833e6f Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Wed, 21 Oct 2020 09:54:01 -0700 Subject: [PATCH 2/2] Update index.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrian Heine né Lang --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 582deb8..9be793e 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -"use strict"; +"use strict" const getPrototype = Object.getPrototypeOf || (o => o.__proto__)