Skip to content

Commit 3467fe2

Browse files
authored
Merge PR #488: Cleanup ESM/TypeScript build
2 parents ad8dd40 + fb75f45 commit 3467fe2

File tree

5 files changed

+10
-108
lines changed

5 files changed

+10
-108
lines changed

.babelrc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
{
22
"presets": [["@babel/preset-env", { "modules": false }], "@babel/preset-typescript"],
3-
"plugins": [
4-
"add-module-exports",
5-
[
6-
"module-resolver",
7-
{
8-
"root": ["./"],
9-
"alias": {
10-
"src": "./src"
11-
}
12-
}
13-
],
14-
["babel-plugin-inline-import", { "extensions": [".sql"] }]
15-
],
3+
"plugins": ["add-module-exports", ["babel-plugin-inline-import", { "extensions": [".sql"] }]],
164
"targets": {
175
"node": 14
186
}

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
"scripts": {
9090
"clean": "rimraf lib dist coverage",
9191
"git:changes": "git diff --name-only --diff-filter d | xargs",
92-
"ts:check": "ttsc --noEmit",
93-
"ts:changes": "ttsc --noEmit --incremental",
92+
"ts:check": "tsc --noEmit",
93+
"ts:changes": "tsc --noEmit --incremental",
9494
"lint": "eslint --cache .",
9595
"lint:changes": "sh -c eslint --cache $(yarn git:changes)",
9696
"pretty": "prettier --write .",
@@ -103,7 +103,7 @@
103103
"pre-commit": "npm-run-all --parallel ts:changes lint:changes",
104104
"grammar": "nearleyc src/parser/grammar.ne -o src/parser/grammar.ts",
105105
"build:babel": "babel src --out-dir lib --extensions .ts --source-maps",
106-
"build:types": "ttsc --module commonjs --emitDeclarationOnly --isolatedModules",
106+
"build:types": "tsc --emitDeclarationOnly --isolatedModules",
107107
"build:minified": "webpack --config webpack.prod.js && cp dist/sql-formatter.min.cjs dist/sql-formatter.min.js",
108108
"build": "yarn grammar && npm-run-all --parallel build:babel build:types build:minified",
109109
"release": "release-it"
@@ -131,13 +131,11 @@
131131
"@types/nearley": "^2.11.2",
132132
"@typescript-eslint/eslint-plugin": "^5.21.0",
133133
"@typescript-eslint/parser": "^5.21.0",
134-
"@zerollup/ts-transform-paths": "^1.7.18",
135134
"babel-eslint": "^10.1.0",
136135
"babel-jest": "^28.1.2",
137136
"babel-loader": "^8.1.0",
138137
"babel-plugin-add-module-exports": "^1.0.2",
139138
"babel-plugin-inline-import": "^3.0.0",
140-
"babel-plugin-module-resolver": "^4.1.0",
141139
"dedent-js": "^1.0.1",
142140
"eslint": "^8.14.0",
143141
"eslint-config-airbnb-base": "^15.0.0",
@@ -152,7 +150,6 @@
152150
"rimraf": "^3.0.2",
153151
"ts-jest": "^28.0.5",
154152
"ts-loader": "^9.3.1",
155-
"ttypescript": "^1.5.13",
156153
"typescript": "^4.7.4",
157154
"webpack": "^5.74.0",
158155
"webpack-cli": "^4.9.1",

src/parser/createParser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Parser as NearleyParser, Grammar } from 'nearley';
1+
import nearley from 'nearley';
22

33
import Tokenizer from '../lexer/Tokenizer.js';
44
import { disambiguateTokens } from '../lexer/disambiguateTokens.js';
@@ -8,6 +8,8 @@ import grammar from './grammar.js';
88
import LexerAdapter from './LexerAdapter.js';
99
import { createEofToken } from '../lexer/token.js';
1010

11+
const { Parser: NearleyParser, Grammar } = nearley;
12+
1113
export interface Parser {
1214
parse(sql: string, paramTypesOverrides: ParamTypes): StatementNode[];
1315
}

tsconfig.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
"rootDirs": ["src"],
77
"outDir": "lib",
88
"baseUrl": "./",
9-
"plugins": [
10-
{
11-
"transform": "@zerollup/ts-transform-paths",
12-
"exclude": ["*"]
13-
}
14-
],
159
"sourceMap": true,
1610
"declaration": true,
1711
"esModuleInterop": true,

yarn.lock

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,20 +1996,6 @@
19961996
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
19971997
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
19981998

1999-
"@zerollup/ts-helpers@^1.7.18":
2000-
version "1.7.18"
2001-
resolved "https://registry.yarnpkg.com/@zerollup/ts-helpers/-/ts-helpers-1.7.18.tgz#747177f6d5abc06c3a0f5dffe7362d365cf0391d"
2002-
integrity sha512-S9zN+y+i5yN/evfWquzSO3lubqPXIsPQf6p9OiPMpRxDx/0totPLF39XoRw48Dav5dSvbIE8D2eAPpXXJxvKwg==
2003-
dependencies:
2004-
resolve "^1.12.0"
2005-
2006-
"@zerollup/ts-transform-paths@^1.7.18":
2007-
version "1.7.18"
2008-
resolved "https://registry.yarnpkg.com/@zerollup/ts-transform-paths/-/ts-transform-paths-1.7.18.tgz#72f705c66690879e51d53c73dc76c4e2518a8c50"
2009-
integrity sha512-YPVUxvWQVzRx1OBN0Pmkd58+R9FcfUJuwTaPUSoi5rKxuXMtxevTXdfi0w5mEaIH8b0DfL+wg0wFDHiJE+S2zA==
2010-
dependencies:
2011-
"@zerollup/ts-helpers" "^1.7.18"
2012-
20131999
acorn-import-assertions@^1.7.6:
20142000
version "1.8.0"
20152001
resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9"
@@ -2258,17 +2244,6 @@ babel-plugin-jest-hoist@^28.1.1:
22582244
"@types/babel__core" "^7.1.14"
22592245
"@types/babel__traverse" "^7.0.6"
22602246

2261-
babel-plugin-module-resolver@^4.1.0:
2262-
version "4.1.0"
2263-
resolved "https://registry.yarnpkg.com/babel-plugin-module-resolver/-/babel-plugin-module-resolver-4.1.0.tgz#22a4f32f7441727ec1fbf4967b863e1e3e9f33e2"
2264-
integrity sha512-MlX10UDheRr3lb3P0WcaIdtCSRlxdQsB1sBqL7W0raF070bGl1HQQq5K3T2vf2XAYie+ww+5AKC/WrkjRO2knA==
2265-
dependencies:
2266-
find-babel-config "^1.2.0"
2267-
glob "^7.1.6"
2268-
pkg-up "^3.1.0"
2269-
reselect "^4.0.0"
2270-
resolve "^1.13.1"
2271-
22722247
babel-plugin-polyfill-corejs2@^0.3.1:
22732248
version "0.3.1"
22742249
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz#440f1b70ccfaabc6b676d196239b138f8a2cfba5"
@@ -3407,14 +3382,6 @@ filter-obj@^1.1.0:
34073382
resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-1.1.0.tgz#9b311112bc6c6127a16e016c6c5d7f19e0805c5b"
34083383
integrity sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==
34093384

3410-
find-babel-config@^1.2.0:
3411-
version "1.2.0"
3412-
resolved "https://registry.yarnpkg.com/find-babel-config/-/find-babel-config-1.2.0.tgz#a9b7b317eb5b9860cda9d54740a8c8337a2283a2"
3413-
integrity sha512-jB2CHJeqy6a820ssiqwrKMeyC6nNdmrcgkKWJWmpoxpE8RKciYJXCcXRq1h2AzCo5I5BJeN2tkGEO3hLTuePRA==
3414-
dependencies:
3415-
json5 "^0.5.1"
3416-
path-exists "^3.0.0"
3417-
34183385
find-cache-dir@^3.3.1:
34193386
version "3.3.2"
34203387
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b"
@@ -3431,13 +3398,6 @@ find-up@^2.1.0:
34313398
dependencies:
34323399
locate-path "^2.0.0"
34333400

3434-
find-up@^3.0.0:
3435-
version "3.0.0"
3436-
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
3437-
integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==
3438-
dependencies:
3439-
locate-path "^3.0.0"
3440-
34413401
find-up@^4.0.0, find-up@^4.1.0:
34423402
version "4.1.0"
34433403
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
@@ -3614,7 +3574,7 @@ glob-to-regexp@^0.4.1:
36143574
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
36153575
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==
36163576

3617-
glob@^7.0.0, glob@^7.1.6:
3577+
glob@^7.0.0:
36183578
version "7.2.3"
36193579
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
36203580
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
@@ -4678,11 +4638,6 @@ json-stable-stringify-without-jsonify@^1.0.1:
46784638
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
46794639
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==
46804640

4681-
json5@^0.5.1:
4682-
version "0.5.1"
4683-
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
4684-
integrity sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==
4685-
46864641
json5@^1.0.1:
46874642
version "1.0.1"
46884643
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
@@ -4785,14 +4740,6 @@ locate-path@^2.0.0:
47854740
p-locate "^2.0.0"
47864741
path-exists "^3.0.0"
47874742

4788-
locate-path@^3.0.0:
4789-
version "3.0.0"
4790-
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
4791-
integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==
4792-
dependencies:
4793-
p-locate "^3.0.0"
4794-
path-exists "^3.0.0"
4795-
47964743
locate-path@^5.0.0:
47974744
version "5.0.0"
47984745
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
@@ -5216,7 +5163,7 @@ p-limit@^1.1.0:
52165163
dependencies:
52175164
p-try "^1.0.0"
52185165

5219-
p-limit@^2.0.0, p-limit@^2.2.0:
5166+
p-limit@^2.2.0:
52205167
version "2.3.0"
52215168
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
52225169
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
@@ -5230,13 +5177,6 @@ p-locate@^2.0.0:
52305177
dependencies:
52315178
p-limit "^1.1.0"
52325179

5233-
p-locate@^3.0.0:
5234-
version "3.0.0"
5235-
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
5236-
integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==
5237-
dependencies:
5238-
p-limit "^2.0.0"
5239-
52405180
p-locate@^4.1.0:
52415181
version "4.1.0"
52425182
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
@@ -5422,13 +5362,6 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0:
54225362
dependencies:
54235363
find-up "^4.0.0"
54245364

5425-
pkg-up@^3.1.0:
5426-
version "3.1.0"
5427-
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-3.1.0.tgz#100ec235cc150e4fd42519412596a28512a0def5"
5428-
integrity sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==
5429-
dependencies:
5430-
find-up "^3.0.0"
5431-
54325365
prelude-ls@^1.2.1:
54335366
version "1.2.1"
54345367
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@@ -5767,11 +5700,6 @@ [email protected]:
57675700
dependencies:
57685701
x-path "^0.0.2"
57695702

5770-
reselect@^4.0.0:
5771-
version "4.1.6"
5772-
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.1.6.tgz#19ca2d3d0b35373a74dc1c98692cdaffb6602656"
5773-
integrity sha512-ZovIuXqto7elwnxyXbBtCPo9YFEr3uJqj2rRbcOOog1bmu2Ag85M4hixSwFWyaBMKXNgvPaJ9OSu9SkBPIeJHQ==
5774-
57755703
resolve-alpn@^1.2.0:
57765704
version "1.2.1"
57775705
resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9"
@@ -5799,7 +5727,7 @@ resolve.exports@^1.1.0:
57995727
resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9"
58005728
integrity sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==
58015729

5802-
resolve@>=1.9.0, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.13.1, resolve@^1.20.0, resolve@^1.22.0:
5730+
resolve@^1.1.6, resolve@^1.10.0, resolve@^1.20.0, resolve@^1.22.0:
58035731
version "1.22.0"
58045732
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198"
58055733
integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==
@@ -6419,13 +6347,6 @@ tsutils@^3.21.0:
64196347
dependencies:
64206348
tslib "^1.8.1"
64216349

6422-
ttypescript@^1.5.13:
6423-
version "1.5.13"
6424-
resolved "https://registry.yarnpkg.com/ttypescript/-/ttypescript-1.5.13.tgz#c3bcb760599fe49157d30c5d5895a0023cbb7f30"
6425-
integrity sha512-KT/RBfGGlVJFqEI8cVvI3nMsmYcFvPSZh8bU0qX+pAwbi7/ABmYkzn7l/K8skw0xmYjVCoyaV6WLsBQxdadybQ==
6426-
dependencies:
6427-
resolve ">=1.9.0"
6428-
64296350
type-check@^0.4.0, type-check@~0.4.0:
64306351
version "0.4.0"
64316352
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"

0 commit comments

Comments
 (0)