Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update acorn, fix tests #883

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function BabelModePlugin({ types }) {

const { directives } = node

if (!directives) {
return false;
}

let { length } = directives

while (length--) {
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
},
parser: "eslint-plugin-import/memo-parser",
parserOptions: {
ecmaVersion: 10,
ecmaVersion: 11,
parser: "babel-eslint",
sourceType: "module"
},
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/esm
/node_modules
/src/vendor
/test/env/home/.local/share/Trash
/test/env/prefix/bin
/test/env/prefix/node
/test/fixture/find-path/created
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ matrix:
include:
- node_js: 12
env: HARMONY=true
allow_failures:
- node_js: 8

before_install:
- npm i -g npm
Expand Down
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ environment:
- nodejs_version: 10
- nodejs_version: 8

matrix:
allow_failures:
- nodejs_version: 8

cache:
- '%APPDATA%\npm-cache'

Expand Down
22,293 changes: 12,648 additions & 9,645 deletions package-lock.json

Large diffs are not rendered by default.

108 changes: 54 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,80 +28,80 @@
"test:prod": "node script/test.js --prod"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-optional-catch-binding": "^7.2.0",
"@babel/plugin-transform-arrow-functions": "^7.2.0",
"@babel/plugin-transform-block-scoping": "^7.4.4",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/register": "^7.4.4",
"@babel/runtime": "^7.4.5",
"@std/esm": "^0.25.5",
"@types/node": "^10.14.10",
"acorn": "^6.1.1",
"@babel/core": "^7.10.5",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-optional-catch-binding": "^7.10.4",
"@babel/plugin-transform-arrow-functions": "^7.10.4",
"@babel/plugin-transform-block-scoping": "^7.10.5",
"@babel/plugin-transform-flow-strip-types": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.10.5",
"@babel/polyfill": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/register": "^7.10.5",
"@babel/runtime": "^7.10.5",
"@hapi/lab": "^22.0.5",
"@std/esm": "^0.26.0",
"@types/node": "^14.0.24",
"acorn": "^7.3.1",
"ava": "^1.4.1",
"babel-eslint": "^10.0.2",
"babel-loader": "^8.0.6",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"babel-plugin-transform-for-of-as-array": "^1.1.1",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-plugin-transform-remove-debugger": "^6.9.4",
"bluebird": "^3.5.5",
"bluebird": "^3.7.2",
"chai": "^4.2.0",
"core-js": "^2.6.9",
"download": "^7.1.0",
"eslint": "^5.16.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-node": "^7.0.1",
"execa": "^1.0.0",
"download": "^8.0.0",
"eslint": "^7.5.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0",
"execa": "^4.0.3",
"express": "^4.17.1",
"flow-remove-types": "^1.2.3",
"fs-extra": "^7.0.1",
"global-prefix": "^1.0.2",
"globby": "^8.0.2",
"flow-remove-types": "^2.129.0",
"fs-extra": "^9.0.1",
"global-prefix": "^3.0.0",
"globby": "^11.0.1",
"golden-fleece": "^1.0.9",
"hard-rejection": "^1.0.0",
"html-minifier": "^3.5.21",
"husky": "^2.7.0",
"jasmine": "^3.4.0",
"jest": "^24.8.0",
"json-6": "^1.0.2",
"lab": "^17.3.0",
"hard-rejection": "^2.1.0",
"html-minifier": "^4.0.0",
"husky": "^4.2.5",
"jasmine": "^3.5.0",
"jest": "^26.0.0",
"json-6": "^1.0.7",
"lit-node": "^0.1.1",
"mocha": "^5.2.0",
"mocha": "^8.0.1",
"mock-require": "^3.0.3",
"mock-stdio": "^1.0.3",
"module-alias": "^2.2.0",
"newrelic": "^4.13.1",
"module-alias": "^2.2.2",
"newrelic": "^6.11.0",
"nop": "^1.0.0",
"nyc": "^14.1.1",
"nyc": "^15.1.0",
"optimize-js-plugin": "0.0.4",
"pm2": "3.2.4",
"postcss": "^7.0.17",
"proxyquire": "^2.1.0",
"pm2": "^4.4.0",
"postcss": "^7.0.32",
"proxyquire": "^2.1.3",
"require-inject": "^1.4.4",
"requizzle": "^0.2.2",
"rewire": "^4.0.1",
"semver": "^5.7.0",
"sinon": "^7.3.2",
"sleep": "^6.1.0",
"requizzle": "^0.2.3",
"rewire": "^5.0.0",
"semver": "^7.3.2",
"sinon": "^9.0.2",
"sleep": "^6.3.0",
"sqreen": "^1.31.0",
"strip-ansi": "^5.2.0",
"terser": "^3.17.0",
"terser-webpack-plugin": "^1.3.0",
"strip-ansi": "^6.0.0",
"terser": "^4.8.0",
"terser-webpack-plugin": "^3.0.7",
"test262-parser": "^2.2.0",
"trash": "^4.3.0",
"ts-node": "^7.0.1",
"trash": "^6.1.1",
"ts-node": "^8.10.2",
"typescript": "^3.5.2",
"unexpected": "11.5.0",
"unused-webpack-plugin": "2.2.0",
"unexpected": "^11.5.0",
"unused-webpack-plugin": "^2.2.0",
"webpack": "^4.35.2",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.5",
"yargs": "^12.0.5"
"yargs": "^15.4.1"
},
"files": [
"index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/acorn/parser/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function init() {
["The keyword 'yield' is reserved", UNEXPECTED_STRICT_MODE_RESERVED_WORD],
["Unterminated string constant", INVALID_OR_UNEXPECTED_TOKEN],
["Unterminated template", UNTERMINATED_TEMPLATE],
["new.target can only be used in functions", ILLEGAL_NEW_TARGET]
["'new.target' can only be used in functions", ILLEGAL_NEW_TARGET]
])

const Plugin = {
Expand Down
3 changes: 3 additions & 0 deletions src/module/esm/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ function load(request, parent, isMain = false, preload) {
(parentType !== TYPE_CJS &&
parentType !== TYPE_PSEUDO &&
! parentCJS.cache))) {

try {
entry.module.parent = void 0
} catch {/* jest freezes module */}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/module/esm/parse-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function parseLoad(request, parent, isMain) {
validateDeep(entry)
}

load(request, parent, isMain)
entry = load(request, parent, isMain)
}
} finally {
moduleState.requireDepth -= 1
Expand Down
2 changes: 1 addition & 1 deletion src/parse/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function init() {
return Parser.create("", {
allowAwaitOutsideFunction: true,
allowReturnOutsideFunction: true,
ecmaVersion: 10
ecmaVersion: 11
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function init() {
const defaultOptions = {
allowAwaitOutsideFunction: true,
allowReturnOutsideFunction: false,
ecmaVersion: 10,
ecmaVersion: 11,
sourceType: "module",
strict: void 0
}
Expand Down
4 changes: 2 additions & 2 deletions src/util/parse-json6.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse } from "json-6"
import JSON6 from "json-6"
import quotifyJSON from "./quotify-json.js"
import shared from "../shared.js"

Expand All @@ -12,7 +12,7 @@ function init() {
if (typeof string === "string" &&
string.length) {
try {
return parse(string)
return JSON6.parse(string)
} catch {}
}

Expand Down
3 changes: 2 additions & 1 deletion test/check-hook-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function node(args) {
}

function shell(command) {
return execa.shell(command, {
return execa(command, {
shell: true,
cwd: testPath,
reject: false
})
Expand Down
16 changes: 11 additions & 5 deletions test/file-extension-tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "assert"
import require from "./require.js"
import require2 from "./require.js"

describe("file extension tests", () => {
it("should not error importing `.mjs` files", () =>
Expand All @@ -23,8 +23,14 @@ describe("file extension tests", () => {
]
.map((request) =>
import(request)
.then(assert.fail)
.catch(({ code }) => assert.strictEqual(code, "ERR_UNKNOWN_FILE_EXTENSION"))
.then(
() => assert.fail(request + " imported without error, but should have failed"),
(e) => {
if (e.code === "ERR_ASSERTION") {
throw e
}
assert.strictEqual(e.code, "ERR_UNKNOWN_FILE_EXTENSION")
})
))
)

Expand All @@ -38,7 +44,7 @@ describe("file extension tests", () => {
)

it("should not error requiring extensionless files", () => {
require("./fixture/ext/no-ext-cjs")
require2("./fixture/ext/no-ext-cjs")
})

it("should error importing files with unknown extensions from ESM", () =>
Expand Down Expand Up @@ -66,7 +72,7 @@ describe("file extension tests", () => {
)

it("should not error requiring unknown extensions", () => {
require("./fixture/ext/a.unknown-ext-cjs")
require2("./fixture/ext/a.unknown-ext-cjs")
})

it('should error importing non `.mjs` ES modules from `.mjs` files with `options.mode` of "strict"', () =>
Expand Down
7 changes: 1 addition & 6 deletions test/fixture/scenario/babel-error/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
"use strict"

module.exports = {
presets: [
["@babel/env", {
modules: false
}]
],
sourceMaps: false
plugins: [require.resolve('./error.js')]
}
5 changes: 5 additions & 0 deletions test/fixture/scenario/babel-error/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { declare } = require("@babel/helper-plugin-utils")

module.exports = declare((api) => {
throw new Error("BABEL_ERROR")
})
2 changes: 1 addition & 1 deletion test/fixture/scenario/babel-error/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import.meta
// yolo
2 changes: 1 addition & 1 deletion test/fixture/scenario/jasmine-helpers/jasmine.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"test.js"
],
"helpers": [
"../../../../"
"../../../../esm.js"
]
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/jest-config-globals/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"JEST_CONFIG_GLOBAL": "JEST_CONFIG_GLOBAL_VALUE"
},
"testEnvironment": "node",
"testURL": "file://",
"testURL": "http://localhost",
"transform": {}
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/jest-console/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"testURL": "file://"
"testURL": "http://localhost"
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/jest-context/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"testEnvironment": "node",
"testURL": "file://"
"testURL": "http://localhost"
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/jest-cycle/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"testURL": "file://"
"testURL": "http://localhost"
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/jest-mock-require/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"testURL": "file://"
"testURL": "http://localhost"
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/jest-module-cache/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"testURL": "file://"
"testURL": "http://localhost"
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/jest-process/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"testEnvironment": "node",
"testURL": "file://"
"testURL": "http://localhost"
}
2 changes: 1 addition & 1 deletion test/fixture/scenario/lab-babel/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import assert from "assert"
import { script } from "lab"
import { script } from "@hapi/lab"
import add from "./add.flow.js"

const lab = script()
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/scenario/lab/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "assert"
import { script } from "lab"
import { script } from "@hapi/lab"
import { add } from "../../math/math.esm.js"

const lab = script()
Expand Down
Loading