Skip to content

Commit

Permalink
fix: build file include tsd typing
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Dec 26, 2017
1 parent 9cf1f4a commit be83467
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 10 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nerv-build",
"private": true,
"version": "0.3.0-alpha.0",
"version": "1.0.0",
"workspaces": [
"packages/*"
],
Expand All @@ -21,7 +21,8 @@
"test:coverage": "jest --coverage",
"test:karma": "karma start karma.conf.js --single-run",
"test:karma:watch": "npm run test:karma -- no-single-run",
"build": "npm run clean && lerna exec -- rollup -c && node afterbuild.js",
"build": "npm run clean && lerna exec -- rollup -c && npm run build:typing && node afterbuild.js && npm run size",
"build:typing": "rimraf lib && tsc && lerna exec -- node ../../typing.js",
"size": "gzip-size ./packages/nerv/dist/nerv.min.js",
"build:esm": "lerna exec -- rollup -c --environment TARGET:esm",
"build:umd": "lerna exec -- rollup -c --environment TARGET:umd",
Expand Down Expand Up @@ -65,6 +66,7 @@
"babel-preset-es3": "^1.0.1",
"babel-preset-stage-0": "^6.22.0",
"coveralls": "^2.13.1",
"dts-bundle": "^0.7.3",
"es3ify-webpack-plugin": "^0.0.1",
"es5-polyfill": "0.0.5",
"es6-promise": "^4.1.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/nerv-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
},
"homepage": "https://github.com/NervJS/nerv.git",
"dependencies": {
"nervjs": "1.0.0"
"nervjs": "1.0.0",
"nerv-shared": "1.0.0",
"nerv-utils": "1.0.0"
}
}
6 changes: 6 additions & 0 deletions packages/nerv-devtools/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const typescript = require('rollup-plugin-typescript2')
const alias = require('rollup-plugin-alias')
const { join } = require('path')
function resolver (path) {
return join(__dirname, path)
}
const cwd = process.cwd()
module.exports = {
input: resolver('src/index.ts'),
output: [
Expand All @@ -22,6 +24,10 @@ module.exports = {
nervjs: 'Nerv'
},
plugins: [
alias({
'nerv-shared': join(cwd, '../nerv-shared/dist/index'),
'nerv-utils': join(cwd, '../nerv-utils/dist/index')
}),
typescript({
typescript: require('typescript')
})
Expand Down
3 changes: 2 additions & 1 deletion packages/nerv-devtools/src/devtools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// tslint:disable-next-line:no-var-requires
import { options } from 'nervjs'
import { isComposite, isWidget, isVText, isValidElement } from 'nerv-shared'
const isArray = Array.isArray
import { isArray } from 'nerv-utils'

/**
* Return a ReactElement-compatible object for the current state of a Nerv
* component.
Expand Down
2 changes: 1 addition & 1 deletion packages/nerv/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export default {
findDOMNode,
isValidElement,
unmountComponentAtNode
}
} as any
2 changes: 1 addition & 1 deletion packages/nerv/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { noop, CompositeComponent, StatelessComponent } from 'nerv-shared'

type optionsHook = (vnode: CompositeComponent | StatelessComponent) => void
export type optionsHook = (vnode: CompositeComponent | StatelessComponent) => void

const options: {
afterMount: optionsHook
Expand Down
5 changes: 3 additions & 2 deletions packages/nerv/src/vdom/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
VirtualChildren,
VirtualNode,
isValidElement,
EMPTY_CHILDREN
EMPTY_CHILDREN,
VNode
} from 'nerv-shared'
import { isString, isArray, isNumber } from 'nerv-utils'

Expand Down Expand Up @@ -33,7 +34,7 @@ function h (type: string, props: Props, children?: VirtualChildren) {
props.namespace,
props.owner,
props.ref
)
) as VNode
}

function addChildren (
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"noUnusedLocals": true,
"strictNullChecks": true,
"sourceMap": true,
"declaration": false,
"declaration": true,
"baseUrl": ".",
"paths": {
"nervjs": ["packages/nerv/src"],
Expand Down
21 changes: 21 additions & 0 deletions typing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const dts = require('dts-bundle')
const { join } = require('path')

const cwd = process.cwd()
const pkgJSON = require(join(cwd, 'package.json'))

if (pkgJSON.name === 'nerv-redux') {
return
}

try {
const name = pkgJSON.name === 'nervjs' ? 'nerv' : pkgJSON.name
dts.bundle({
main: join(__dirname, 'lib', 'packages', name, 'src/index.d.ts'),
name: pkgJSON.name,
out: join(cwd, 'dist/index.d.ts')
})
console.log(`${pkgJSON.name} in typings is DONE`)
} catch (e) {
throw Error(e)
}
59 changes: 58 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,37 @@
# yarn lockfile v1


"@types/detect-indent@0.1.30":
version "0.1.30"
resolved "https://registry.npmjs.org/@types/detect-indent/-/detect-indent-0.1.30.tgz#dc682bb412b4e65ba098e70edad73b4833fb910d"

"@types/glob@5.0.30":
version "5.0.30"
resolved "https://registry.npmjs.org/@types/glob/-/glob-5.0.30.tgz#1026409c5625a8689074602808d082b2867b8a51"
dependencies:
"@types/minimatch" "*"
"@types/node" "*"

"@types/jasmine@^2.6.0":
version "2.6.0"
resolved "https://registry.npmjs.org/@types/jasmine/-/jasmine-2.6.0.tgz#997b41a27752b4850af2683bc4a8d8222c25bd02"

"@types/node@^8.0.26":
"@types/minimatch@*":
version "3.0.2"
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.2.tgz#09c06877e478a5d5f32ce5017c2eb2b33006f6f5"

"@types/mkdirp@0.3.29":
version "0.3.29"
resolved "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-0.3.29.tgz#7f2ad7ec55f914482fc9b1ec4bb1ae6028d46066"

"@types/node@*", "@types/node@^8.0.26":
version "8.0.26"
resolved "https://registry.npmjs.org/@types/node/-/node-8.0.26.tgz#4d58be925306fd22b1141085535a0268b8beb189"

"@types/node@8.0.0":
version "8.0.0"
resolved "https://registry.npmjs.org/@types/node/-/node-8.0.0.tgz#acaa89247afddc7967e9902fd11761dadea1a555"

"@types/sinon@^2.3.3":
version "2.3.3"
resolved "https://registry.npmjs.org/@types/sinon/-/sinon-2.3.3.tgz#1f20b96f954b4997a09c1c0a20264aaba6b00147"
Expand Down Expand Up @@ -2077,6 +2100,13 @@ des.js@^1.0.0:
inherits "^2.0.1"
minimalistic-assert "^1.0.0"

detect-indent@^0.2.0:
version "0.2.0"
resolved "https://registry.npmjs.org/detect-indent/-/detect-indent-0.2.0.tgz#042914498979ac2d9f3c73e4ff3e6877d3bc92b6"
dependencies:
get-stdin "^0.1.0"
minimist "^0.1.0"

detect-indent@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208"
Expand Down Expand Up @@ -2147,6 +2177,19 @@ dot-prop@^3.0.0:
dependencies:
is-obj "^1.0.0"

dts-bundle@^0.7.3:
version "0.7.3"
resolved "https://registry.npmjs.org/dts-bundle/-/dts-bundle-0.7.3.tgz#372b7bb69c820782e6382f400739a69dced3d59a"
dependencies:
"@types/detect-indent" "0.1.30"
"@types/glob" "5.0.30"
"@types/mkdirp" "0.3.29"
"@types/node" "8.0.0"
commander "^2.9.0"
detect-indent "^0.2.0"
glob "^6.0.4"
mkdirp "^0.5.0"

duplexer2@0.0.2:
version "0.0.2"
resolved "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db"
Expand Down Expand Up @@ -2922,6 +2965,10 @@ get-port@^3.2.0:
version "3.2.0"
resolved "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz#dd7ce7de187c06c8bf353796ac71e099f0980ebc"

get-stdin@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/get-stdin/-/get-stdin-0.1.0.tgz#5998af24aafc802d15c82c685657eeb8b10d4a91"

get-stdin@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe"
Expand Down Expand Up @@ -2996,6 +3043,16 @@ glob@^5.0.15:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^6.0.4:
version "6.0.4"
resolved "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22"
dependencies:
inflight "^1.0.4"
inherits "2"
minimatch "2 || 3"
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
version "7.1.2"
resolved "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
Expand Down

0 comments on commit be83467

Please sign in to comment.