Skip to content

Commit

Permalink
Improve build (#30)
Browse files Browse the repository at this point in the history
* improve build: cjs vs esm, no tests
* include sideEffects false
* move lodash to devDeps
  • Loading branch information
Matt Shwery authored Mar 9, 2021
1 parent 4e737d1 commit 3e53f3a
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 78 deletions.
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"name": "@segment/fql",
"version": "1.9.1",
"main": "dist/index.js",
"browser": "dist/index.js",
"bin": "dist/index.js",
"main": "dist/cjs/index.js",
"browser": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"bin": "dist/cjs/index.js",
"sideEffects": false,
"scripts": {
"test": "jest",
"build": "rm -rf dist && tsc",
"build": "rm -rf dist && tsc && tsc -p tsconfig.cjs.json",
"lint": "tslint src/**/*.ts",
"prepare": "npm run build"
},
"files": [
"package.json",
"dist",
"src"
"dist"
],
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/lodash": "^4.14.168",
"jest": "^26.6.1",
"lodash": "^4.17.21",
"ts-jest": "^26.4.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
Expand Down Expand Up @@ -51,8 +55,5 @@
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS; printf \"\n\n\""
}
},
"dependencies": {
"@types/lodash": "^4.14.121",
"lodash": "^4.17.11"
}
"dependencies": {}
}
30 changes: 0 additions & 30 deletions src/access.test.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/access.ts

This file was deleted.

13 changes: 11 additions & 2 deletions src/ast.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import ast, { AbstractSyntaxType, astToTokens, astToString, isASTNode, ASTNode } from './ast'
import lex from './lexer'
import { TokenType, t } from './token'
import { getASTNode, getToken } from './access'
import { TokenType, Token, t } from './token'
import { get } from 'lodash'

// Assertively get a child as an ASTNode
function getASTNode(arg: ASTNode, path: string): ASTNode {
return get(arg, path)
}

// Assertively get a child as a Token
function getToken(arg: ASTNode, path: string): Token {
return get(arg, path)
}

test('root node has root type', () => {
const { tokens } = lex(`"foobang"`)
const { node } = ast(tokens)
Expand Down
6 changes: 0 additions & 6 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { lex, t, types, ast, astToTokens } from './index'
import unlex from './unlexer'
import { getASTNode, getToken } from './index'

test('access items are exported', () => {
expect(getASTNode).toBeTruthy()
expect(getToken).toBeTruthy()
})

test('we can use the imported lexer', () => {
expect(lex(`message.event = "Order Completed" and amount > 100`).tokens).toEqual([
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ export {
isASTNode,
ASTNode
} from './ast'
export { getASTNode, getToken } from './access'
7 changes: 7 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs"
}
}
14 changes: 6 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "es2020",
"target": "es6",
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": false,
"moduleResolution": "node",
"esModuleInterop": true,
"sourceMap": true,
"outDir": "dist",
"outDir": "dist/esm",
"baseUrl": ".",
"declaration": true,
"resolveJsonModule": true,
"paths": {
"*": ["node_modules/*", "src/types/*"]
}
"resolveJsonModule": true
},
"lib": ["es2017"],
"include": ["src/**/*"],
"exclude": ["tests/**/*"]
"include": ["src"],
"exclude": ["src/*.test.ts"]
}
17 changes: 9 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,10 @@
jest-diff "^26.0.0"
pretty-format "^26.0.0"

"@types/lodash@^4.14.121":
version "4.14.121"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.121.tgz#9327e20d49b95fc2bf983fc2f045b2c6effc80b9"
integrity sha512-ORj7IBWj13iYufXt/VXrCNMbUuCTJfhzme5kx9U/UtcIPdJYuvPDUAlHlbNhz/8lKCLy9XGIZnGrqXOtQbPGoQ==
"@types/lodash@^4.14.168":
version "4.14.168"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008"
integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q==

"@types/node@*":
version "14.14.6"
Expand Down Expand Up @@ -2383,15 +2383,16 @@ lodash.sortby@^4.7.0:
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=

lodash@^4.17.11:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"

lodash@^4.17.19:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

make-dir@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand Down

0 comments on commit 3e53f3a

Please sign in to comment.