Skip to content

Commit

Permalink
- Enhancement: Add ESM distribution, with module property in `packa…
Browse files Browse the repository at this point in the history
…ge.json`

- Refactoring: Add Rollup/Babel/Terser
- Build: Have generator file produce consumable source files directly rather than logging to console
- Linting: Switch from JSHint to ESLint (using rules, e.g., `indent` and `prefer-const`, in place on other estools project)
- Testing: Convert coffeescript test files to ES6
- Testing: Add nyc
- Testing: Check unmatched high surrogates and full coverage for AST
    expressions (further true `isExpression` and `isStatement`'s and
    false `isProblematicIfStatement`), bringing to 100% coverage
- Travis: Drop previous versions for 10, 12, 14
  • Loading branch information
brettz9 committed Apr 29, 2020
1 parent 6281a63 commit d7b8a33
Show file tree
Hide file tree
Showing 23 changed files with 1,414 additions and 1,179 deletions.
5 changes: 5 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
["@babel/preset-env"]
]
}
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
dist

!.eslintrc.js
coverage

src/es5-identifier.js
src/es6-identifier.js
48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true
},
extends: 'eslint:recommended',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
overrides: [{
files: '.eslintrc.js',
parserOptions: {
sourceType: 'script'
},
rules: {
strict: 'error'
}
}, {
files: 'test/**',
globals: {
expect: true
},
env: {
mocha: true
}
}],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018
},
rules: {
semi: ['error'],
indent: ['error', 4, { SwitchCase: 1 }],
'prefer-const': ['error'],
'no-var': ['error'],
'prefer-destructuring': ['error'],
'object-shorthand': ['error'],
'object-curly-spacing': ['error', 'always'],
quotes: ['error', 'single'],
'quote-props': ['error', 'as-needed'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'prefer-template': ['error']
}
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
dist
coverage
16 changes: 0 additions & 16 deletions .jshintrc

This file was deleted.

9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: node_js
node_js:
- "0.10"
- "0.11"

matrix:
allow_failures:
- node_js: "0.11"
- 10
- 12
- 14
144 changes: 0 additions & 144 deletions lib/ast.js

This file was deleted.

135 changes: 0 additions & 135 deletions lib/code.js

This file was deleted.

35 changes: 29 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
"description": "utility box for ECMAScript language tools",
"homepage": "https://github.com/estools/esutils",
"bugs": "https://github.com/estools/esutils/issues",
"main": "lib/utils.js",
"main": "dist/esutils.min.js",
"module": "dist/esutils.esm.min.js",
"version": "2.0.4-dev",
"engines": {
"node": ">=0.10.0"
},
"directories": {
"lib": "./lib"
"lib": "./dist"
},
"files": [
"LICENSE.BSD",
"README.md",
"lib"
"dist"
],
"keywords": [
"ecmascript"
Expand All @@ -33,18 +34,40 @@
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/register": "^7.9.0",
"@rollup/plugin-babel": "^5.0.0",
"chai": "~4.2.0",
"coffeescript": "^2.5.1",
"jshint": "2.11.0",
"eslint": "^6.8.0",
"mocha": "~7.1.2",
"nyc": "^15.0.1",
"regenerate": "~1.4.0",
"rollup": "^2.7.3",
"rollup-plugin-terser": "^5.3.0",
"unicode-13.0.0": "^0.8.0"
},
"license": "BSD-2-Clause",
"nyc": {
"branches": 100,
"lines": 100,
"functions": 100,
"statements": 100,
"reporter": [
"html",
"text"
],
"exclude": [
"test"
]
},
"scripts": {
"build": "rollup -c",
"test": "npm run lint && npm run unit-test",
"lint": "jshint lib/*.js",
"unit-test": "mocha --require chai/register-expect --require coffeescript/register test/**",
"lint": "eslint .",
"unit-test": "nyc mocha --require @babel/register --require chai/register-expect --require coffeescript/register test/**",
"generate-regex": "node tools/generate-identifier-regex.js"
}
}
45 changes: 45 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { terser } from 'rollup-plugin-terser';

import babel from '@rollup/plugin-babel';

/**
* @external RollupConfig
* @type {PlainObject}
* @see {@link https://rollupjs.org/guide/en#big-list-of-options}
*/

/**
* @param {PlainObject} [config= {}]
* @param {boolean} [config.minifying=false]
* @param {string} [config.format='umd']
* @returns {external:RollupConfig}
*/
function getRollupObject ({ minifying, format = 'umd' } = {}) {
const nonMinified = {
input: 'src/utils.js',
output: {
format,
sourcemap: minifying,
file: `dist/esutils${
format === 'umd' ? '' : `.${format}`
}${minifying ? '.min' : ''}.js`,
name: 'esutils'
},
plugins: [
babel({
babelHelpers: 'bundled'
})
]
};
if (minifying) {
nonMinified.plugins.push(terser());
}
return nonMinified;
}

export default [
getRollupObject({ minifying: true, format: 'umd' }),
getRollupObject({ minifying: false, format: 'umd' }),
getRollupObject({ minifying: true, format: 'esm' }),
getRollupObject({ minifying: false, format: 'esm' })
];
Loading

0 comments on commit d7b8a33

Please sign in to comment.