Skip to content

Commit b0c9307

Browse files
committed
use babel for acorn-node itself
1 parent aebf9e2 commit b0c9307

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ node_modules
2828
package-lock.json
2929

3030
lib/*
31+
/index.js
32+
/walk.js

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"build:acorn-class-fields": "babel node_modules/acorn-class-fields --out-dir lib/acorn-class-fields",
4646
"build:acorn-static-class-features": "babel node_modules/acorn-static-class-features --out-dir lib/acorn-static-class-features",
4747
"build:acorn-private-class-elements": "babel node_modules/acorn-private-class-elements --out-dir lib/acorn-private-class-elements",
48+
"build:self": "babel src --out-dir .",
4849
"build": "npm-run-all --parallel build:*"
4950
},
5051
"standard": {

index.js renamed to src/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
var acorn = require('acorn')
2-
var xtend = require('xtend')
3-
var setPrototypeOf = require('setprototypeof')
42

53
var CJSParser = acorn.Parser
4+
// Required paths should be relative to the package root, because Babel outputs this file there.
65
.extend(require('./lib/acorn-class-fields'))
76
.extend(require('./lib/acorn-static-class-features'))
87
.extend(require('./lib/acorn-numeric-separator'))
@@ -11,28 +10,29 @@ var ESModulesParser = CJSParser
1110

1211
function mapOptions (opts) {
1312
if (!opts) opts = {}
14-
return xtend({
13+
return {
1514
ecmaVersion: 2020,
1615
allowHashBang: true,
17-
allowReturnOutsideFunction: true
18-
}, opts)
16+
allowReturnOutsideFunction: true,
17+
...opts
18+
}
1919
}
2020

2121
function defaultOptionsPlugin (P) {
22-
function DefaultOptionsParser (opts, src) {
23-
P.call(this, mapOptions(opts), src)
22+
return class DefaultOptionsParser extends P {
23+
constructor(opts, src) {
24+
super(mapOptions(opts), src)
25+
}
2426
}
25-
setPrototypeOf(DefaultOptionsParser, P)
26-
DefaultOptionsParser.prototype = P.prototype
27-
return DefaultOptionsParser
2827
}
2928

3029
function getParser (opts) {
3130
if (!opts) opts = {}
3231
return opts.sourceType === 'module' ? ESModulesParser : CJSParser
3332
}
3433

35-
module.exports = exports = xtend(acorn, {
34+
module.exports = exports = {
35+
...acorn,
3636
Parser: CJSParser,
3737
ESModulesParser: ESModulesParser,
3838

@@ -45,4 +45,4 @@ module.exports = exports = xtend(acorn, {
4545
tokenizer: function tokenizer (src, opts) {
4646
return getParser(opts).tokenizer(src, opts)
4747
}
48-
})
48+
}

walk.js renamed to src/walk.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
var xtend = require('xtend')
21
var walk = require('acorn-walk')
32

4-
var base = xtend(walk.base)
3+
var base = {
4+
...walk.base
5+
}
56

67
function simple (node, visitors, baseVisitor, state, override) {
78
return walk.simple(node, visitors, baseVisitor || base, state, override)

0 commit comments

Comments
 (0)