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

support compile js file #306

Closed
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/preset-env",
{"modules": false,
"targets": ["last 2 versions", "ie >= 11","> 1%"],
"corejs": 3,
"useBuiltIns": "usage"
}
]
]
}
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "dt-sql-parser",
"version": "4.0.1",
"type": "module",
"authors": "DTStack Corporation",
"description": "SQL Parsers for BigData, built with antlr4",
"keywords": [
Expand All @@ -23,6 +24,7 @@
"prepublishOnly": "npm run build",
"antlr4": "node ./scripts/antlr4.js",
"build": "rm -rf dist && tsc",
"rollup:build": "rm -rf dist && rollup -c",
"check-types": "tsc -p ./tsconfig.json && tsc -p ./test/tsconfig.json",
"test": "NODE_OPTIONS=--max_old_space_size=4096 && jest",
"release": "node ./scripts/release.js",
Expand All @@ -33,9 +35,14 @@
},
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@commitlint/cz-commitlint": "^17.7.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@swc/core": "^1.3.60",
"@swc/jest": "^0.2.26",
"@types/jest": "^29.5.1",
Expand All @@ -50,6 +57,8 @@
"jest": "^29.5.0",
"lint-staged": "12.5.0",
"prettier": "^3.0.3",
"rollup": "^4.17.2",
"rollup-plugin-typescript2": "^0.36.0",
"standard-version": "^9.5.0",
"typescript": "^5.0.4",
"yargs-parser": "^21.1.1"
Expand Down
37 changes: 37 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import ts from "rollup-plugin-typescript2"

export default [
// browser-friendly UMD build
{
input: 'src/index.ts',
output: {
name: 'dtSqlParser',
file: 'dist/index.umd.js',
format: 'umd'
},
plugins: [
ts(),
babel(),
resolve(), // so Rollup can find `ms`
commonjs() // so Rollup can convert `ms` to an ES module
]
},

// CommonJS (for Node) and ES module (for bundlers) build.
// (We could have three entries in the configuration array
// instead of two, but it's quicker to generate multiple
// builds from a single configuration where possible, using
// an array for the `output` option, where we can specify
// `file` and `format` for each target)
// {
// input: 'src/main.js',
// external: ['ms'],
// output: [
// { file: pkg.main, format: 'cjs' },
// { file: pkg.module, format: 'es' }
// ]
// }
];
10 changes: 8 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"outDir": "./dist/",
"sourceMap": false,
"allowJs":true,
"target": "es6",
"target": "es5",
"module": "ESNext",
"moduleResolution": "node",
"declaration": true,
Expand All @@ -13,9 +13,15 @@
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"downlevelIteration":true,
"importHelpers":true,
"forceConsistentCasingInFileNames": true,
"lib": [
"ESNext",
"es5",
"ES6",
"es7",
"ES2015.Collection",
"ES2015.Iterable",
"DOM"
],
"skipLibCheck": true,
Expand Down