diff --git a/.babelrc.json b/.babelrc.json new file mode 100644 index 0000000..60fdb32 --- /dev/null +++ b/.babelrc.json @@ -0,0 +1,8 @@ +{ + "presets": [ + ["@babel/preset-env"] + ], + "plugins": [ + ["transform-es2017-object-entries"] + ] +} diff --git a/.editorconfig b/.editorconfig index a22fb99..26bf60b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,3 +16,6 @@ indent_size = 2 [*.pegjs] indent_size = 2 + +[*.yml] +indent_size = 2 diff --git a/.travis.yml b/.travis.yml index 6ba643e..9a00218 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ script: - npm run build - npm run test:ci node_js: - - 8 - 10 - 12 @@ -13,3 +12,10 @@ matrix: - name: Lint node_js: 12 script: npm run lint + - name: node 8 (old deps) + node_js: 8 + before_script: npm install --no-save "eslint@5" + - name: node 6 (old deps; skip build) + node_js: 6 + before_script: npm install --no-save "eslint@5" mocha@6.2.2 nyc@14.1.1 + script: npm run test:ci diff --git a/package.json b/package.json index 12f62b3..fc12407 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "build:parser": "rm parser.js && pegjs --cache --format umd -o \"parser.js\" \"grammar.pegjs\"", "build:browser": "rollup -c", "build": "npm run build:parser && npm run build:browser", - "mocha": "mocha --require chai/register-assert --require esm tests", + "mocha": "mocha --require chai/register-assert --require @babel/register tests", "test": "nyc npm run mocha && npm run lint", "test:ci": "npm run mocha", "lint": "eslint ." @@ -51,22 +51,26 @@ "query" ], "devDependencies": { + "@babel/core": "^7.9.0", + "@babel/preset-env": "^7.9.0", + "@babel/register": "^7.9.0", "@rollup/plugin-commonjs": "^11.0.2", "@rollup/plugin-json": "^4.0.2", "@rollup/plugin-node-resolve": "^7.1.1", + "babel-plugin-transform-es2017-object-entries": "0.0.5", "chai": "^4.2.0", "eslint": "^6.8.0", - "esm": "^3.2.25", "esprima": "~4.0.1", "mocha": "^7.1.1", "nyc": "^15.0.0", "pegjs": "~0.10.0", "rollup": "^1.32.0", + "rollup-plugin-babel": "^4.4.0", "rollup-plugin-terser": "^5.2.0" }, "license": "BSD-3-Clause", "engines": { - "node": ">=8.0" + "node": ">=0.10" }, "dependencies": { "estraverse": "^5.0.0" diff --git a/rollup.config.js b/rollup.config.js index dedfb2d..b2f36dc 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,6 +4,8 @@ import nodeResolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; +import babel from 'rollup-plugin-babel'; + /** * @external RollupConfig * @type {PlainObject} @@ -30,7 +32,8 @@ function getRollupObject ({ minifying, format = 'umd' } = {}) { plugins: [ json(), nodeResolve(), - commonjs() + commonjs(), + babel() ] }; if (minifying) { diff --git a/tests/queryAttribute.js b/tests/queryAttribute.js index 646c235..9e717d6 100644 --- a/tests/queryAttribute.js +++ b/tests/queryAttribute.js @@ -177,12 +177,14 @@ describe('Attribute query', function () { ]); }); - it('regexp flag (s)', function () { - const matches = esquery(literal, '[value=/\f.\r/s]'); - assert.includeMembers(matches, [ - literal.body[0].declarations[0].init - ]); - }); + if (parseInt(process.version) >= 8) { + it('regexp flag (s)', function () { + const matches = esquery(literal, '[value=/\f.\r/s]'); + assert.includeMembers(matches, [ + literal.body[0].declarations[0].init + ]); + }); + } it('regexp flag (m)', function () { const matches = esquery(literal, '[value=/^\r/m]');