Skip to content

Commit 1ba81fc

Browse files
authored
fix: update build system to use typescript instead of rollup (#238)
Mostly copied from the coffee-lex config. This is necessary to expose types that decaffeinate can use.
1 parent 356c715 commit 1ba81fc

File tree

6 files changed

+46
-100
lines changed

6 files changed

+46
-100
lines changed

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "decaffeinate-parser",
33
"description": "A better AST for CoffeeScript, inspired by CoffeeScriptRedux.",
4-
"main": "dist/decaffeinate-parser.umd.js",
5-
"jsnext:main": "dist/decaffeinate-parser.es6.js",
4+
"main": "dist/parser.js",
5+
"module": "dist/parser.mjs",
6+
"types": "dist/parser.d.ts",
67
"scripts": {
7-
"prebuild": "rm -rf dist/",
8-
"build": "rollup -c",
8+
"build": "./script/build",
99
"lint": "eslint src test && tslint --config tslint.json --project tsconfig.json --type-check",
1010
"lint-fix": "eslint src test --fix && tslint --config tslint.json --project tsconfig.json --type-check --fix",
1111
"pretest": "npm run lint",
@@ -43,13 +43,9 @@
4343
"babel-plugin-transform-object-rest-spread": "^6.20.1",
4444
"babel-preset-es2015": "^6.13.0",
4545
"babel-register": "^6.7.2",
46-
"babelrc-rollup": "^3.0.0",
4746
"coffee-script-redux": "^2.0.0-beta8",
4847
"eslint": "^4.1.0",
4948
"mocha": "^3.0.0",
50-
"rollup": "^0.42.0",
51-
"rollup-plugin-babel": "^2.7.1",
52-
"rollup-plugin-typescript": "^0.8.1",
5349
"semantic-release": "^6.3.2",
5450
"string-repeat": "^1.1.1",
5551
"ts-node": "^3.0.6",

rollup.config.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

script/build

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
DIST="${DIST:-dist}"
6+
TSC="${TSC:-node_modules/.bin/tsc}"
7+
8+
rm -rf "${DIST}"
9+
10+
echo 'Building ES module version.'
11+
"${TSC}" \
12+
--project . \
13+
--outDir "${DIST}" \
14+
--module ES2015 \
15+
--moduleResolution node
16+
17+
for js in $(find "${DIST}" -name '*.js'); do
18+
mv "${js}" "$(dirname "${js}")/$(basename "${js}" .js).mjs"
19+
done
20+
21+
echo 'Building CommonJS version.'
22+
"${TSC}" \
23+
--project . \
24+
--outDir "${DIST}" \
25+
--module commonjs \
26+
--moduleResolution node
27+
28+
# Restructure.
29+
rm -rf dist/test
30+
mv dist/src/* dist/
31+
rmdir dist/src

test/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { deepEqual } from 'assert';
2-
import { join } from 'path';
3-
import stringify = require('json-stable-stringify');
42
import { readdirSync, readFileSync, writeFileSync } from 'fs';
3+
import * as stringify from 'json-stable-stringify';
4+
import { join } from 'path';
55
import { Node, Program } from '../src/nodes';
66
import { parse } from '../src/parser';
77

tsconfig.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
"compilerOptions": {
33
"strictNullChecks": true,
44
"module": "commonjs",
5-
"typeRoots": ["declarations", "node_modules/@types"],
5+
"typeRoots": ["node_modules/@types"],
66
"declaration": true,
77
"lib": ["es2015"],
88
"experimentalDecorators": true,
99
"noImplicitAny": true,
1010
"noUnusedParameters": true,
1111
"noUnusedLocals": true,
12-
"noEmit": true,
1312
"suppressImplicitAnyIndexErrors": true
14-
}
13+
},
14+
"exclude": [
15+
"node_modules",
16+
"dist/**/*"
17+
]
1518
}

yarn.lock

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ babel-code-frame@^6.22.0:
201201
esutils "^2.0.2"
202202
js-tokens "^3.0.0"
203203

204-
babel-core@6, babel-core@^6.24.1:
204+
babel-core@^6.24.1:
205205
version "6.24.1"
206206
resolved "https://registry.npmjs.org/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83"
207207
dependencies:
@@ -374,7 +374,7 @@ babel-plugin-transform-es2015-block-scoping@^6.24.1:
374374
babel-types "^6.24.1"
375375
lodash "^4.2.0"
376376

377-
babel-plugin-transform-es2015-classes@^6.24.1, babel-plugin-transform-es2015-classes@^6.9.0:
377+
babel-plugin-transform-es2015-classes@^6.24.1:
378378
version "6.24.1"
379379
resolved "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db"
380380
dependencies:
@@ -640,12 +640,6 @@ babel@^6.5.2:
640640
version "6.23.0"
641641
resolved "https://registry.npmjs.org/babel/-/babel-6.23.0.tgz#d0d1e7d803e974765beea3232d4e153c0efb90f4"
642642

643-
babelrc-rollup@^3.0.0:
644-
version "3.0.0"
645-
resolved "https://registry.npmjs.org/babelrc-rollup/-/babelrc-rollup-3.0.0.tgz#fcecdbe3eb6400cf4e769233c1786a2fafe8b56c"
646-
dependencies:
647-
resolve "^1.1.7"
648-
649643
babylon@^6.11.0, babylon@^6.14.1, babylon@^6.15.0, babylon@^6.17.0:
650644
version "6.17.1"
651645
resolved "https://registry.npmjs.org/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f"
@@ -788,10 +782,6 @@ commander@2.9.0, commander@^2.9.0:
788782
dependencies:
789783
graceful-readlink ">= 1.0.0"
790784

791-
compare-versions@2.0.1:
792-
version "2.0.1"
793-
resolved "https://registry.npmjs.org/compare-versions/-/compare-versions-2.0.1.tgz#1edc1f93687fd97a325c59f55e45a07db106aca6"
794-
795785
concat-map@0.0.1:
796786
version "0.0.1"
797787
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -1081,10 +1071,6 @@ estraverse@~4.1.0:
10811071
version "4.1.1"
10821072
resolved "https://registry.npmjs.org/estraverse/-/estraverse-4.1.1.tgz#f6caca728933a850ef90661d0e17982ba47111a2"
10831073

1084-
estree-walker@^0.2.1:
1085-
version "0.2.1"
1086-
resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e"
1087-
10881074
esutils@^2.0.2:
10891075
version "2.0.2"
10901076
resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
@@ -2263,7 +2249,7 @@ resolve-from@^1.0.0:
22632249
version "1.0.1"
22642250
resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
22652251

2266-
resolve@^1.1.7, resolve@^1.3.2:
2252+
resolve@^1.3.2:
22672253
version "1.3.3"
22682254
resolved "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5"
22692255
dependencies:
@@ -2286,38 +2272,6 @@ rimraf@^2.2.8:
22862272
dependencies:
22872273
glob "^7.0.5"
22882274

2289-
rollup-plugin-babel@^2.7.1:
2290-
version "2.7.1"
2291-
resolved "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-2.7.1.tgz#16528197b0f938a1536f44683c7a93d573182f57"
2292-
dependencies:
2293-
babel-core "6"
2294-
babel-plugin-transform-es2015-classes "^6.9.0"
2295-
object-assign "^4.1.0"
2296-
rollup-pluginutils "^1.5.0"
2297-
2298-
rollup-plugin-typescript@^0.8.1:
2299-
version "0.8.1"
2300-
resolved "https://registry.npmjs.org/rollup-plugin-typescript/-/rollup-plugin-typescript-0.8.1.tgz#2ff7eecc21cf6bb2b43fc27e5b688952ce71924a"
2301-
dependencies:
2302-
compare-versions "2.0.1"
2303-
object-assign "^4.0.1"
2304-
rollup-pluginutils "^1.3.1"
2305-
tippex "^2.1.1"
2306-
typescript "^1.8.9"
2307-
2308-
rollup-pluginutils@^1.3.1, rollup-pluginutils@^1.5.0:
2309-
version "1.5.2"
2310-
resolved "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz#1e156e778f94b7255bfa1b3d0178be8f5c552408"
2311-
dependencies:
2312-
estree-walker "^0.2.1"
2313-
minimatch "^3.0.2"
2314-
2315-
rollup@^0.42.0:
2316-
version "0.42.0"
2317-
resolved "https://registry.npmjs.org/rollup/-/rollup-0.42.0.tgz#56e791b3a2f3dd7190bbb80a375675f2fe0f9b23"
2318-
dependencies:
2319-
source-map-support "^0.4.0"
2320-
23212275
run-async@^2.2.0:
23222276
version "2.3.0"
23232277
resolved "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"
@@ -2566,10 +2520,6 @@ through@2, through@^2.3.6, through@~2.3, through@~2.3.1:
25662520
version "2.3.8"
25672521
resolved "https://registry.npmjs.org/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
25682522

2569-
tippex@^2.1.1:
2570-
version "2.3.1"
2571-
resolved "https://registry.npmjs.org/tippex/-/tippex-2.3.1.tgz#a2fd5b7087d7cbfb20c9806a6c16108c2c0fafda"
2572-
25732523
tmp@^0.0.31:
25742524
version "0.0.31"
25752525
resolved "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7"
@@ -2685,10 +2635,6 @@ typedarray@^0.0.6:
26852635
version "0.0.6"
26862636
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
26872637

2688-
typescript@^1.8.9:
2689-
version "1.8.10"
2690-
resolved "https://registry.npmjs.org/typescript/-/typescript-1.8.10.tgz#b475d6e0dff0bf50f296e5ca6ef9fbb5c7320f1e"
2691-
26922638
typescript@^2.2.1:
26932639
version "2.3.3"
26942640
resolved "https://registry.npmjs.org/typescript/-/typescript-2.3.3.tgz#9639f3c3b40148e8ca97fe08a51dd1891bb6be22"

0 commit comments

Comments
 (0)