Skip to content

Commit

Permalink
build: separate src and test tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 20, 2022
1 parent d8c3bbf commit 575f076
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 116 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: 'ci'
on:
push:
branches:
- '**'
pull_request:
branches:
- main
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node version to 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'pnpm'

- run: pnpm install

- name: Run unit tests
run: pnpm run test:unit

# e2e-test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2

# - name: Install pnpm
# uses: pnpm/action-setup@v2

# - name: Set node version to 16
# uses: actions/setup-node@v2
# with:
# node-version: 16
# cache: 'pnpm'

# - run: pnpm install

# - name: Run e2e tests
# run: pnpm run test:e2e

lint-and-test-dts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node version to 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'pnpm'

- run: pnpm install

- name: Run srouce type check
run: pnpm run ts-check

- name: Run eslint
run: pnpm run lint

- name: Run type declaration tests
run: pnpm run test:types
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "vue",
"version": "2.6.14",
"packageManager": "pnpm@7.1.0",
"description": "Reactive, component-oriented view layer for modern web interfaces.",
"main": "dist/vue.runtime.common.js",
"module": "dist/vue.runtime.esm.js",
Expand All @@ -17,17 +18,17 @@
"dev": "rollup -w -c scripts/config.js --environment TARGET:web-full-dev",
"dev:cjs": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-cjs-dev",
"dev:esm": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-esm",
"dev:test": "karma start test/unit/karma.dev.config.ts",
"dev:ssr": "rollup -w -c scripts/config.js --environment TARGET:web-server-renderer",
"dev:compiler": "rollup -w -c scripts/config.js --environment TARGET:web-compiler ",
"build": "node scripts/build.js",
"build:ssr": "npm run build -- web-runtime-cjs,web-server-renderer",
"test": "npm run lint && npm run ts-check && npm run test:types && npm run test:cover && npm run test:e2e -- --env phantomjs && npm run test:ssr",
"test": "npm run lint && npm run ts-check && npm run test:types && npm run test:unit && npm run test:e2e",
"test:unit": "vitest run",
"test:e2e": "npm run build -- web-full-prod,web-server-basic-renderer && node test/e2e/runner.ts",
"test:types": "tsc -p ./types/tsconfig.json",
"lint": "eslint src scripts test",
"ts-check": "tsc --noEmit",
"ts-check": "tsc -p tsconfig.json --noEmit",
"ts-check:test": "tsc -p test/tsconfig.json --noEmit",
"bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js",
"release": "bash scripts/release.sh",
"release:note": "node scripts/gen-release-note.js",
Expand Down
8 changes: 6 additions & 2 deletions packages/vue-server-renderer/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"noEmit": true
"noEmit": true,
"paths": {
"vue": ["../../../types/index.d.ts"]
}
},
"compileOnSave": false,
"include": [
"**/*.ts"
"**/*.ts",
"../../../types"
]
}
8 changes: 2 additions & 6 deletions src/core/util/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import config from '../config'
import { warn } from './debug'
import { inBrowser, inWeex } from './env'
import { inBrowser } from './env'
import { isPromise } from 'shared/util'
import { pushTarget, popTarget } from '../observer/dep'

Expand Down Expand Up @@ -73,11 +73,7 @@ function logError(err, vm, info) {
warn(`Error in ${info}: "${err.toString()}"`, vm)
}
/* istanbul ignore else */
if (
(inBrowser || inWeex) &&
typeof console !== 'undefined' &&
!__SSR_TEST__
) {
if (inBrowser && typeof console !== 'undefined' && !__SSR_TEST__) {
console.error(err)
} else {
throw err
Expand Down
4 changes: 2 additions & 2 deletions src/core/vdom/helpers/update-listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export function updateListeners(
createOnceHandler: Function,
vm: Component
) {
let name, def, cur, old, event
let name, cur, old, event
for (name in on) {
def = cur = on[name]
cur = on[name]
old = oldOn[name]
event = normalizeEvent(name)
if (isUndef(cur)) {
Expand Down
58 changes: 0 additions & 58 deletions test/e2e/nightwatch.config.ts

This file was deleted.

34 changes: 0 additions & 34 deletions test/e2e/runner.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/e2e/specs/todomvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
.assert.notVisible('.footer')
.assert.count('.filters .selected', 1)
.assert.evaluate(function () {
return document.querySelector('.filters .selected').textContent === 'All'
return document.querySelector('.filters .selected')!.textContent === 'All'
})

createNewItem('test')
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/specs/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
.click('.bold')
.assert.visible('#demo ul')
.assert.evaluate(function () {
return document.querySelector('#demo li ul').children.length === 4
return document.querySelector('#demo li ul')!.children.length === 4
})
.assert.containsText('#demo li div span', '[-]')
.assert.containsText('#demo > .item > ul > .item:nth-child(1)', 'hello')
Expand All @@ -24,7 +24,7 @@ module.exports = {
// add items to root
.click('#demo > .item > ul > .add')
.assert.evaluate(function () {
return document.querySelector('#demo li ul').children.length === 5
return document.querySelector('#demo li ul')!.children.length === 5
})
.assert.containsText('#demo > .item > ul > .item:nth-child(1)', 'hello')
.assert.containsText('#demo > .item > ul > .item:nth-child(2)', 'wat')
Expand All @@ -35,7 +35,7 @@ module.exports = {
// add another item
.click('#demo > .item > ul > .add')
.assert.evaluate(function () {
return document.querySelector('#demo li ul').children.length === 6
return document.querySelector('#demo li ul')!.children.length === 6
})
.assert.containsText('#demo > .item > ul > .item:nth-child(1)', 'hello')
.assert.containsText('#demo > .item > ul > .item:nth-child(2)', 'wat')
Expand All @@ -48,7 +48,7 @@ module.exports = {
.assert.visible('#demo ul ul')
.assert.containsText('#demo ul > .item:nth-child(3)', '[-]')
.assert.evaluate(function () {
return document.querySelector('#demo ul ul').children.length === 5
return document.querySelector('#demo ul ul')!.children.length === 5
})

.click('.bold')
Expand All @@ -63,8 +63,8 @@ module.exports = {
.assert.count('.item > ul', 5)
.assert.containsText('#demo ul > .item:nth-child(1)', '[-]')
.assert.evaluate(function () {
const firstItem = document.querySelector('#demo ul > .item:nth-child(1)')
const ul = firstItem.querySelector('ul')
const firstItem = document.querySelector('#demo ul > .item:nth-child(1)')!
const ul = firstItem.querySelector('ul')!
return ul.children.length === 2
})
.end()
Expand Down
37 changes: 37 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"sourceMap": true,
"target": "esnext",
"module": "ESNext",
"moduleResolution": "node",
"strict": true,

"allowJs": true,
"noImplicitAny": false,
"noImplicitThis": false,

"noUnusedLocals": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"removeComments": false,
"jsx": "preserve",
"lib": ["esnext", "dom"],
"types": ["node", "vitest/globals"],
"paths": {
"compiler/*": ["../src/compiler/*"],
"core/*": ["../src/core/*"],

"server/*": ["../src/server/*"],
"sfc/*": ["../src/sfc/*"],
"shared/*": ["../src/shared/*"],

"web/*": ["../src/platforms/web/*"],

"vue": ["../src/platforms/web/entry-runtime-with-compiler"]
}
},
"include": ["../src", "../typescript", "."]
}
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"removeComments": false,
"jsx": "preserve",
"lib": ["esnext", "dom"],
"types": ["node", "vitest/globals"],
"types": ["node"],
"paths": {
"compiler/*": ["src/compiler/*"],
"core/*": ["src/core/*"],
Expand All @@ -33,7 +33,5 @@
"vue": ["src/platforms/web/entry-runtime-with-compiler"]
}
},
"include": ["src", "test-dts", "typescript", "test"],

"exclude": ["node_modules", "packages", "types"]
"include": ["src", "typescript"],
}

0 comments on commit 575f076

Please sign in to comment.