Skip to content

Commit

Permalink
build: basic build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
HcySunYang committed Jan 12, 2019
1 parent 2f45b5b commit e805ab0
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 1,844 deletions.
14 changes: 0 additions & 14 deletions .eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
dist
.rpt2_cache
.history
*.log
*.txt
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,21 @@
"@types/jest": "^23.3.2",
"@types/node": "^10.11.0",
"all-contributors-cli": "^5.6.0",
"bili": "^3.1.2",
"conventional-changelog-cli": "^2.0.11",
"cz-conventional-changelog": "2.1.0",
"eslint": "^5.8.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.0.0",
"husky": "^1.0.0",
"is-builtin-module": "^3.0.0",
"jest": "^23.6.0",
"lerna": "^3.10.5",
"lint-staged": "^7.3.0",
"markdown-toc": "^1.2.0",
"prettier": "^1.14.3",
"prettier-tslint": "^0.4.0",
"rollup": "^1.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-typescript2": "^0.17.0",
"ts-jest": "^23.10.1",
"tslint": "^5.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export interface ParserResult {
name?: string
}

export default function(
export function parser(
source: string,
options: ParserOptions = {}
): ParserResult {
Expand Down
3 changes: 1 addition & 2 deletions packages/parser/lib/parseJavascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
getArgumentFromPropDecorator,
getEmitDecorator
} from '@vuese/utils'
import { isArray } from 'util'

export function parseJavascript(ast: bt.File, options: ParserOptions = {}) {
const seenEvent = new Set()
Expand Down Expand Up @@ -203,7 +202,7 @@ function isAllowPropsType(typeNode: bt.Node): boolean {
function hasFunctionTypeDef(type: PropType): boolean {
if (typeof type === 'string') {
return type.toLowerCase() === 'function'
} else if (isArray(type)) {
} else if (Array.isArray(type)) {
return type.map(a => a.toLowerCase()).some(b => b === 'function')
}
return false
Expand Down
34 changes: 34 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import path from 'path'
import typescript from 'rollup-plugin-typescript2'
import moduleResolve from 'rollup-plugin-node-resolve'
import isBuiltinModule from 'is-builtin-module'

function resolveInput(projectDir) {
return path.resolve('packages', `${projectDir}/lib/index.ts`)
}

function resolveOnput(projectDir) {
return path.resolve('packages', `${projectDir}/dist/index.js`)
}

export default {
input: resolveInput('parser'),
external(id) {
return id.includes('node_modules')
},
plugins: [
typescript({
cacheRoot: path.resolve(__dirname, 'node_modules/.rts2_cache')
}),
moduleResolve()
],
output: {
file: resolveOnput('parser'),
format: 'cjs'
},
onwarn(warning, warn) {
if (warning.code === 'UNRESOLVED_IMPORT' && isBuiltinModule(warning.source))
return
warn(warning)
}
}
Empty file added scripts/build.js
Empty file.
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"strictNullChecks": true,
"removeComments": false,
"moduleResolution": "node",
"declaration": true,
"jsx": "preserve",
"lib": [
"esnext",
Expand Down

0 comments on commit e805ab0

Please sign in to comment.