Skip to content

Commit

Permalink
Add package.json files to src/ dirs with type: module
Browse files Browse the repository at this point in the history
So that the source can also be loaded directly in node, if you want to.

Issue #732
  • Loading branch information
marijnh committed Aug 12, 2020
1 parent f7462e1 commit ee1ce37
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 71 deletions.
4 changes: 2 additions & 2 deletions acorn-loose/src/expression.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LooseParser} from "./state"
import {isDummy} from "./parseutil"
import {LooseParser} from "./state.js"
import {isDummy} from "./parseutil.js"
import {tokTypes as tt} from "acorn"

const lp = LooseParser.prototype
Expand Down
12 changes: 6 additions & 6 deletions acorn-loose/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
// tangle.

import {defaultOptions} from "acorn"
import {LooseParser} from "./state"
import "./tokenize"
import "./statement"
import "./expression"
import {LooseParser} from "./state.js"
import "./tokenize.js"
import "./statement.js"
import "./expression.js"

export {LooseParser} from "./state"
export {isDummy} from "./parseutil"
export {LooseParser} from "./state.js"
export {isDummy} from "./parseutil.js"

defaultOptions.tabSize = 4

Expand Down
3 changes: 3 additions & 0 deletions acorn-loose/src/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
2 changes: 1 addition & 1 deletion acorn-loose/src/state.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Parser, SourceLocation, tokTypes as tt, Node, lineBreak, isNewLine} from "acorn"
import {dummyValue} from "./parseutil"
import {dummyValue} from "./parseutil.js"

function noop() {}

Expand Down
4 changes: 2 additions & 2 deletions acorn-loose/src/statement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LooseParser} from "./state"
import {isDummy} from "./parseutil"
import {LooseParser} from "./state.js"
import {isDummy} from "./parseutil.js"
import {getLineInfo, tokTypes as tt} from "acorn"

const lp = LooseParser.prototype
Expand Down
4 changes: 2 additions & 2 deletions acorn-loose/src/tokenize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {tokTypes as tt, Token, isNewLine, SourceLocation, getLineInfo, lineBreakG} from "acorn"
import {LooseParser} from "./state"
import {dummyValue} from "./parseutil"
import {LooseParser} from "./state.js"
import {dummyValue} from "./parseutil.js"

const lp = LooseParser.prototype

Expand Down
3 changes: 3 additions & 0 deletions acorn-walk/src/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
10 changes: 5 additions & 5 deletions acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
//
// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser

import {types as tt} from "./tokentype"
import {Parser} from "./state"
import {DestructuringErrors} from "./parseutil"
import {lineBreak} from "./whitespace"
import {functionFlags, SCOPE_ARROW, SCOPE_SUPER, SCOPE_DIRECT_SUPER, BIND_OUTSIDE, BIND_VAR} from "./scopeflags"
import {types as tt} from "./tokentype.js"
import {Parser} from "./state.js"
import {DestructuringErrors} from "./parseutil.js"
import {lineBreak} from "./whitespace.js"
import {functionFlags, SCOPE_ARROW, SCOPE_SUPER, SCOPE_DIRECT_SUPER, BIND_OUTSIDE, BIND_VAR} from "./scopeflags.js"

const pp = Parser.prototype

Expand Down
30 changes: 15 additions & 15 deletions acorn/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
//
// [walk]: util/walk.js

import {Parser} from "./state"
import "./parseutil"
import "./statement"
import "./lval"
import "./expression"
import "./location"
import "./scope"
import {Parser} from "./state.js"
import "./parseutil.js"
import "./statement.js"
import "./lval.js"
import "./expression.js"
import "./location.js"
import "./scope.js"

import {defaultOptions} from "./options"
import {Position, SourceLocation, getLineInfo} from "./locutil"
import {Node} from "./node"
import {TokenType, types as tokTypes, keywords as keywordTypes} from "./tokentype"
import {TokContext, types as tokContexts} from "./tokencontext"
import {isIdentifierChar, isIdentifierStart} from "./identifier"
import {Token} from "./tokenize"
import {isNewLine, lineBreak, lineBreakG, nonASCIIwhitespace} from "./whitespace"
import {defaultOptions} from "./options.js"
import {Position, SourceLocation, getLineInfo} from "./locutil.js"
import {Node} from "./node.js"
import {TokenType, types as tokTypes, keywords as keywordTypes} from "./tokentype.js"
import {TokContext, types as tokContexts} from "./tokencontext.js"
import {isIdentifierChar, isIdentifierStart} from "./identifier.js"
import {Token} from "./tokenize.js"
import {isNewLine, lineBreak, lineBreakG, nonASCIIwhitespace} from "./whitespace.js"

export const version = "7.4.0"
export {
Expand Down
4 changes: 2 additions & 2 deletions acorn/src/location.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Parser} from "./state"
import {Position, getLineInfo} from "./locutil"
import {Parser} from "./state.js"
import {Position, getLineInfo} from "./locutil.js"

const pp = Parser.prototype

Expand Down
2 changes: 1 addition & 1 deletion acorn/src/locutil.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {lineBreakG} from "./whitespace"
import {lineBreakG} from "./whitespace.js"

// These are used when `options.locations` is on, for the
// `startLoc` and `endLoc` properties.
Expand Down
8 changes: 4 additions & 4 deletions acorn/src/lval.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {types as tt} from "./tokentype"
import {Parser} from "./state"
import {has} from "./util"
import {BIND_NONE, BIND_OUTSIDE, BIND_LEXICAL} from "./scopeflags"
import {types as tt} from "./tokentype.js"
import {Parser} from "./state.js"
import {has} from "./util.js"
import {BIND_NONE, BIND_OUTSIDE, BIND_LEXICAL} from "./scopeflags.js"

const pp = Parser.prototype

Expand Down
4 changes: 2 additions & 2 deletions acorn/src/node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Parser} from "./state"
import {SourceLocation} from "./locutil"
import {Parser} from "./state.js"
import {SourceLocation} from "./locutil.js"

export class Node {
constructor(parser, pos, loc) {
Expand Down
4 changes: 2 additions & 2 deletions acorn/src/options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {has, isArray} from "./util"
import {SourceLocation} from "./locutil"
import {has, isArray} from "./util.js"
import {SourceLocation} from "./locutil.js"

// A second optional argument can be given to further configure
// the parser process. These options are recognized:
Expand Down
3 changes: 3 additions & 0 deletions acorn/src/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
6 changes: 3 additions & 3 deletions acorn/src/parseutil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {types as tt} from "./tokentype"
import {Parser} from "./state"
import {lineBreak, skipWhiteSpace} from "./whitespace"
import {types as tt} from "./tokentype.js"
import {Parser} from "./state.js"
import {lineBreak, skipWhiteSpace} from "./whitespace.js"

const pp = Parser.prototype

Expand Down
4 changes: 2 additions & 2 deletions acorn/src/scope.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Parser} from "./state"
import {SCOPE_VAR, SCOPE_FUNCTION, SCOPE_TOP, SCOPE_ARROW, SCOPE_SIMPLE_CATCH, BIND_LEXICAL, BIND_SIMPLE_CATCH, BIND_FUNCTION} from "./scopeflags"
import {Parser} from "./state.js"
import {SCOPE_VAR, SCOPE_FUNCTION, SCOPE_TOP, SCOPE_ARROW, SCOPE_SIMPLE_CATCH, BIND_LEXICAL, BIND_SIMPLE_CATCH, BIND_FUNCTION} from "./scopeflags.js"

const pp = Parser.prototype

Expand Down
12 changes: 6 additions & 6 deletions acorn/src/state.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {reservedWords, keywords} from "./identifier"
import {types as tt} from "./tokentype"
import {lineBreak} from "./whitespace"
import {getOptions} from "./options"
import {wordsRegexp} from "./util"
import {SCOPE_TOP, SCOPE_FUNCTION, SCOPE_ASYNC, SCOPE_GENERATOR, SCOPE_SUPER, SCOPE_DIRECT_SUPER} from "./scopeflags"
import {reservedWords, keywords} from "./identifier.js"
import {types as tt} from "./tokentype.js"
import {lineBreak} from "./whitespace.js"
import {getOptions} from "./options.js"
import {wordsRegexp} from "./util.js"
import {SCOPE_TOP, SCOPE_FUNCTION, SCOPE_ASYNC, SCOPE_GENERATOR, SCOPE_SUPER, SCOPE_DIRECT_SUPER} from "./scopeflags.js"

export class Parser {
constructor(options, input, startPos) {
Expand Down
14 changes: 7 additions & 7 deletions acorn/src/statement.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {types as tt} from "./tokentype"
import {Parser} from "./state"
import {lineBreak, skipWhiteSpace} from "./whitespace"
import {isIdentifierStart, isIdentifierChar, keywordRelationalOperator} from "./identifier"
import {has} from "./util"
import {DestructuringErrors} from "./parseutil"
import {functionFlags, SCOPE_SIMPLE_CATCH, BIND_SIMPLE_CATCH, BIND_LEXICAL, BIND_VAR, BIND_FUNCTION} from "./scopeflags"
import {types as tt} from "./tokentype.js"
import {Parser} from "./state.js"
import {lineBreak, skipWhiteSpace} from "./whitespace.js"
import {isIdentifierStart, isIdentifierChar, keywordRelationalOperator} from "./identifier.js"
import {has} from "./util.js"
import {DestructuringErrors} from "./parseutil.js"
import {functionFlags, SCOPE_SIMPLE_CATCH, BIND_SIMPLE_CATCH, BIND_LEXICAL, BIND_VAR, BIND_FUNCTION} from "./scopeflags.js"

const pp = Parser.prototype

Expand Down
6 changes: 3 additions & 3 deletions acorn/src/tokencontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// given point in the program is loosely based on sweet.js' approach.
// See https://github.com/mozilla/sweet.js/wiki/design

import {Parser} from "./state"
import {types as tt} from "./tokentype"
import {lineBreak} from "./whitespace"
import {Parser} from "./state.js"
import {types as tt} from "./tokentype.js"
import {lineBreak} from "./whitespace.js"

export class TokContext {
constructor(token, isExpr, preserveSpace, override, generator) {
Expand Down
12 changes: 6 additions & 6 deletions acorn/src/tokenize.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {isIdentifierStart, isIdentifierChar} from "./identifier"
import {types as tt, keywords as keywordTypes} from "./tokentype"
import {Parser} from "./state"
import {SourceLocation} from "./locutil"
import {RegExpValidationState} from "./regexp"
import {lineBreak, lineBreakG, isNewLine, nonASCIIwhitespace} from "./whitespace"
import {isIdentifierStart, isIdentifierChar} from "./identifier.js"
import {types as tt, keywords as keywordTypes} from "./tokentype.js"
import {Parser} from "./state.js"
import {SourceLocation} from "./locutil.js"
import {RegExpValidationState} from "./regexp.js"
import {lineBreak, lineBreakG, isNewLine, nonASCIIwhitespace} from "./whitespace.js"

// Object type used to represent tokens. Note that normally, tokens
// simply exist as properties on the parser object. This is only
Expand Down

0 comments on commit ee1ce37

Please sign in to comment.