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

Experiment with rollup bundling #1092

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions eslint-bridge/bin/server
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node

const server = require("../lib/server");
server.start(process.argv[2]);
const server = require("../bundle");
server.start(process.argv[2]);
6 changes: 6 additions & 0 deletions eslint-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@
"jest": "23.6.0",
"jest-sonar-reporter": "1.3.0",
"prettier": "1.14.2",
"rollup": "^0.66.2",
"rollup-plugin-commonjs": "^9.1.8",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-typescript2": "^0.17.0",
"ts-jest": "23.1.4",
"typescript": "3.0.3"
},
"dependencies": {
"body-parser": "1.18.3",
"circular-json": "^0.5.7",
"eslint": "5.6.0",
"eslint-plugin-sonarjs": "0.2.0",
"espree": "4.0.0",
Expand Down
47 changes: 47 additions & 0 deletions eslint-bridge/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import typescript from 'rollup-plugin-typescript2'
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';

export default {
input: 'src/server.ts',
output: {
// name: 'eslintBridge',
file: 'bundle.js',
format: 'cjs',
},
external: [
// it seems strange that we need to list this explicitly
'fs', 'net', 'events', 'http', 'path', 'stream', 'os', 'url', 'util', 'crypto', 'assert', 'zlib', 'querystring', 'buffer', 'module', 'tty'
],
plugins: [
resolve(),
commonjs({
include: 'node_modules/**'
}),
typescript({
typescript: require('typescript'),
rollupCommonJSResolveHack: true,
}),
json({
// All JSON files will be parsed by default,
// but you can also specifically include/exclude files
include: 'node_modules/**',
exclude: ['node_modules/foo/**', 'node_modules/bar/**'],

// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false

// specify indentation for the generated default export —
// defaults to '\t'
indent: ' ',

// ignores indent and generates the smallest code
compact: true, // Default: false

// generate a named export for every property of the JSON object
namedExports: true // Default: true
})
],
}
4 changes: 2 additions & 2 deletions eslint-bridge/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as espree from "espree";
import { SourceCode, Linter } from "eslint";
import espree from "espree";
import { Linter, SourceCode } from "eslint";

const PARSER_CONFIG: Linter.ParserOptions = {
tokens: true,
Expand Down
4 changes: 2 additions & 2 deletions eslint-bridge/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { Server } from "http";
import * as express from "express";
import * as bodyParser from "body-parser";
import express from "express";
import bodyParser from "body-parser";
import { AnalysisInput, analyze } from "./analyzer";
import { AddressInfo } from "net";

Expand Down
7 changes: 5 additions & 2 deletions eslint-bridge/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"module": "es6",
"lib": ["dom", "es2017"],
"declaration": true,
"esModuleInterop": true,
"moduleResolution": "node",
"outDir": "lib",
"strict": true,
"sourceMap": true,
"noUnusedLocals": true,
"noUnusedParameters": true
"noUnusedParameters": true,
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*", "./typings/**/*.d.ts"]
}