Skip to content

Commit bbd4d39

Browse files
authoredDec 18, 2019
Update test suite to Node.js 13.x without esm (#40)
* upgrade tests for Node.js 13 * 13 testing * update build script to modules
1 parent 0dbc4f1 commit bbd4d39

File tree

6 files changed

+23
-12
lines changed

6 files changed

+23
-12
lines changed
 

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ git:
22
depth: 1
33
language: node_js
44
node_js:
5-
- '10'
5+
- '13'
66

77
before_install:
88
- npm install

‎build.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const fs = require('fs');
2-
const terser = require('terser');
1+
import fs from 'fs';
2+
import terser from 'terser';
33

44
const MINIFY = true;
55

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "dist/lexer.cjs",
66
"module": "dist/lexer.js",
77
"scripts": {
8-
"test": "mocha -r esm -b -u tdd test/*.js",
8+
"test": "mocha -b -u tdd test/*.cjs",
99
"build": "node build.js && babel dist/lexer.js | terser -o dist/lexer.cjs",
1010
"build-wasm": "make lib/lexer.wasm && node build.js",
1111
"bench": "node --experimental-modules --expose-gc bench/index.js",
@@ -18,7 +18,6 @@
1818
"@babel/cli": "^7.5.5",
1919
"@babel/core": "^7.5.5",
2020
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
21-
"esm": "^3.0.84",
2221
"kleur": "^2.0.2",
2322
"mocha": "^5.2.0",
2423
"terser": "^4.1.4"

‎src/lexer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ void tryParseExportStatement () {
228228
ch = commentWhitespace();
229229
const char16_t* startPos = pos;
230230
ch = readToWsOrPunctuator(ch);
231-
// stops on [ { destructurings
232-
if (ch == '{' || ch == '[') {
231+
// stops on [ { destructurings or =
232+
if (ch == '{' || ch == '[' || ch == '=') {
233233
pos--;
234234
return;
235235
}

‎test/_unit.js ‎test/_unit.cjs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import assert from 'assert';
2-
import { parse, init } from '../dist/lexer.js';
1+
const assert = require('assert');
2+
3+
let parse;
4+
const init = (async () => {
5+
let init;
6+
({ parse, init } = await import('../dist/lexer.js'));
7+
await init;
8+
})();
39

410
suite('Invalid syntax', () => {
511
beforeEach(async () => await init);

‎test/integration.js ‎test/integration.cjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import assert from 'assert';
2-
import fs from 'fs';
3-
import { parse, init } from '../dist/lexer.js';
1+
const fs = require('fs');
2+
const assert = require('assert');
3+
4+
let parse;
5+
const init = (async () => {
6+
let init;
7+
({ parse, init } = await import('../dist/lexer.js'));
8+
await init;
9+
})();
410

511
const files = fs.readdirSync('test/samples')
612
.map(f => `test/samples/${f}`)

0 commit comments

Comments
 (0)
Please sign in to comment.