Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: move to monorepo
  • Loading branch information
yyx990803 committed May 31, 2022
1 parent b3a8ccf commit 9f74f20
Show file tree
Hide file tree
Showing 79 changed files with 15,605 additions and 609 deletions.
37 changes: 22 additions & 15 deletions .github/CONTRIBUTING.md
Expand Up @@ -25,6 +25,7 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
- Make sure `npm test` passes. (see [development setup](#development-setup))

- If adding a new feature:

- Add accompanying test case.
- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it.

Expand All @@ -35,12 +36,12 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before

## Development Setup

You will need [Node.js](http://nodejs.org) **version 8+**, [Java Runtime Environment](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (for running Selenium server during e2e tests) and [yarn](https://yarnpkg.com/en/docs/install).
You will need [Node.js](http://nodejs.org) **version 12+** and [pnpm](https://pnpm.io/).

After cloning the repo, run:

``` bash
$ yarn # install the dependencies of the project
```bash
$ pnpm i # install the dependencies of the project
```

### Committing Changes
Expand All @@ -49,17 +50,20 @@ Commit messages should follow the [commit message convention](./COMMIT_CONVENTIO

### Commonly used NPM scripts

``` bash
```bash
# watch and auto re-build dist/vue.js
$ npm run dev

# watch and auto re-run unit tests in Chrome
$ npm run dev:test
# run unit tests
$ npm run test:unit

# run specific tests in watch mode
$ npx vitest {test_file_name_pattern_to_match}

# build all dist files, including npm packages
$ npm run build

# run the full test suite, including linting/type checking
# run the full test suite, including unit/e2e/type checking
$ npm test
```

Expand All @@ -79,9 +83,17 @@ The default test script will do the following: lint with ESLint -> type check wi

See [dist/README.md](https://github.com/vuejs/vue/blob/dev/dist/README.md) for more details on dist files.

- **`flow`**: contains type declarations for [Flow](https://flowtype.org/). These declarations are loaded **globally** and you will see them used in type annotations in normal source code.
- **`types`**: contains public types published to npm. These were hand-authored before we moved the codebase from Flow to TypeScript. To ensure backwards compatibility, we keep using these manually authored types.

Types for new features added in 2.7 (Composition API) are auto-generated from source code as `types/v3-generated.d.ts` and re-exported from `types/index.d.ts`.

- **`typescript`**: contains type declarations added when we ported the codebase from Flow to TypeScript. These types should be considered internal - they care less about type inference for end-user scenarios and prioritize working with internal source code.

- **`packages`**:

- **`packages`**: contains `vue-server-renderer` and `vue-template-compiler`, which are distributed as separate NPM packages. They are automatically generated from the source code and always have the same version with the main `vue` package.
- `vue-server-renderer` and `vue-template-compiler` are distributed as separate NPM packages. They are automatically generated from the source code and always have the same version with the main `vue` package.

- `compiler-sfc` is an internal package that is distributed as part of the main `vue` package. It's aliased and can be imported as `vue/compiler-sfc` similar to Vue 3.

- **`test`**: contains all tests. The unit tests are written with [Jasmine](http://jasmine.github.io/2.3/introduction.html) and run with [Karma](http://karma-runner.github.io/0.13/index.html). The e2e tests are written for and run with [Nightwatch.js](http://nightwatchjs.org/).

Expand Down Expand Up @@ -111,17 +123,12 @@ The default test script will do the following: lint with ESLint -> type check wi

Entry files for dist builds are located in their respective platform directory.

Each platform module contains three parts: `compiler`, `runtime` and `server`, corresponding to the three directories above. Each part contains platform-specific modules/utilities which are imported and injected to the core counterparts in platform-specific entry files. For example, the code implementing the logic behind `v-bind:class` is in `platforms/web/runtime/modules/class.js` - which is imported in `entries/web-runtime.js` and used to create the browser-specific vdom patching function.
Each platform module contains three parts: `compiler`, `runtime` and `server`, corresponding to the three directories above. Each part contains platform-specific modules/utilities which are imported and injected to the core counterparts in platform-specific entry files. For example, the code implementing the logic behind `v-bind:class` is in `platforms/web/runtime/modules/class.js` - which is imported in `platforms/web/entry-runtime.ts` and used to create the browser-specific vdom patching function.

- **`sfc`**: contains single-file component (`*.vue` files) parsing logic. This is used in the `vue-template-compiler` package.

- **`shared`**: contains utilities shared across the entire codebase.

- **`types`**: contains TypeScript type definitions

- **`test`**: contains type definitions tests


## Financial Contribution

As a pure community-driven project without major corporate backing, we also welcome financial contributions via GitHub Sponsors and OpenCollective. Please consult the [Sponsor Page](https://vuejs.org/sponsor/) for more details.
Expand Down
14 changes: 7 additions & 7 deletions .gitignore
Expand Up @@ -4,13 +4,13 @@ node_modules
explorations
TODOs.md
RELEASE_NOTE*.md
packages/vue-server-renderer/basic.js
packages/vue-server-renderer/build.dev.js
packages/vue-server-renderer/build.prod.js
packages/vue-server-renderer/server-plugin.js
packages/vue-server-renderer/client-plugin.js
packages/vue-template-compiler/build.js
packages/vue-template-compiler/browser.js
packages/server-renderer/basic.js
packages/server-renderer/build.dev.js
packages/server-renderer/build.prod.js
packages/server-renderer/server-plugin.js
packages/server-renderer/client-plugin.js
packages/compiler-sfc/build.js
packages/compiler-sfc/browser.js
.vscode
dist
temp
Expand Down
1 change: 1 addition & 0 deletions compiler-sfc/index.d.ts
@@ -0,0 +1 @@
export * from '@vue/compiler-sfc'
1 change: 1 addition & 0 deletions compiler-sfc/index.js
@@ -0,0 +1 @@
module.exports = require('@vue/compiler-sfc')
4 changes: 4 additions & 0 deletions compiler-sfc/package.json
@@ -0,0 +1,4 @@
{
"main": "index.js",
"types": "index.d.ts"
}
38 changes: 15 additions & 23 deletions package.json
Expand Up @@ -11,22 +11,24 @@
"files": [
"src",
"dist/*.js",
"types/*.d.ts"
"types/*.d.ts",
"compiler-sfc",
"packages/compiler-sfc"
],
"sideEffects": false,
"scripts": {
"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:ssr": "rollup -w -c scripts/config.js --environment TARGET:web-server-renderer",
"dev:compiler": "rollup -w -c scripts/config.js --environment TARGET:web-compiler ",
"dev": "rollup -w -c scripts/config.js --environment TARGET:full-dev",
"dev:cjs": "rollup -w -c scripts/config.js --environment TARGET:runtime-cjs-dev",
"dev:esm": "rollup -w -c scripts/config.js --environment TARGET:runtime-esm",
"dev:ssr": "rollup -w -c scripts/config.js --environment TARGET:server-renderer",
"dev:compiler": "rollup -w -c scripts/config.js --environment TARGET:compiler ",
"build": "node scripts/build.js",
"build:ssr": "npm run build -- web-runtime-cjs,web-server-renderer",
"build:ssr": "npm run build -- runtime-cjs,server-renderer",
"build:types": "rimraf temp && tsc --declaration --emitDeclarationOnly --outDir temp && api-extractor run",
"test": "npm run ts-check && npm run test:types && npm run test:unit && npm run test:e2e && npm run test:ssr",
"test:unit": "vitest run test/unit",
"test:ssr": "npm run build:ssr && vitest run test/ssr",
"test:e2e": "npm run build -- web-full-prod,web-server-renderer-basic && vitest run test/e2e",
"test:ssr": "npm run build:ssr && vitest run server-renderer",
"test:e2e": "npm run build -- full-prod,server-renderer-basic && vitest run test/e2e",
"test:transition": "karma start test/transition/karma.conf.js",
"test:types": "npm run build:types && tsc -p ./types/tsconfig.json",
"format": "prettier --write --parser typescript \"(src|test|packages|types)/**/*.ts\"",
Expand Down Expand Up @@ -62,6 +64,9 @@
"url": "https://github.com/vuejs/vue/issues"
},
"homepage": "https://github.com/vuejs/vue#readme",
"dependencies": {
"@vue/compiler-sfc": "2.6.14"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.24.2",
"@rollup/plugin-alias": "^3.1.9",
Expand All @@ -70,19 +75,14 @@
"@rollup/plugin-replace": "^4.0.0",
"@types/he": "^1.1.2",
"@types/node": "^17.0.30",
"acorn": "^8.7.1",
"acorn-walk": "^8.2.0",
"chalk": "^4.0.0",
"commitizen": "^4.2.4",
"conventional-changelog": "^3.1.25",
"cross-spawn": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"de-indent": "^1.0.2",
"esbuild": "^0.14.39",
"escodegen": "^2.0.0",
"file-loader": "^3.0.1",
"hash-sum": "^2.0.0",
"he": "^1.2.0",
"de-indent": "^1.0.2",
"jasmine-core": "^4.1.1",
"jsdom": "^19.0.0",
"karma": "^6.3.20",
Expand All @@ -92,27 +92,19 @@
"karma-jasmine": "^5.0.1",
"lint-staged": "^12.4.1",
"lodash": "^4.17.21",
"lodash.template": "^4.4.0",
"lodash.uniq": "^4.5.0",
"lru-cache": "^7.8.1",
"marked": "^4.0.6",
"memory-fs": "^0.5.0",
"prettier": "^2.6.2",
"puppeteer": "^14.1.1",
"resolve": "^1.22.0",
"rimraf": "^3.0.2",
"rollup": "^2.70.2",
"rollup-plugin-typescript2": "^0.31.2",
"serialize-javascript": "^6.0.0",
"shelljs": "^0.8.5",
"source-map": "0.5.6",
"terser": "^5.13.1",
"todomvc-app-css": "^2.4.2",
"ts-node": "^10.7.0",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"vitest": "^0.12.6",
"webpack": "^4.46.0",
"yorkie": "^2.0.0"
},
"config": {
Expand Down
28 changes: 28 additions & 0 deletions packages/compiler-sfc/package.json
@@ -0,0 +1,28 @@
{
"name": "@vue/compiler-sfc",
"version": "2.6.14",
"description": "compiler-sfc for Vue 2",
"main": "dist/compiler-sfc.js",
"types": "dist/compiler-sfc.d.ts",
"files": ["dist"],
"dependencies": {
"@babel/parser": "^7.16.4",
"source-map": "^0.6.1",
"postcss": "^8.1.10"
},
"devDependencies": {
"@types/estree": "^0.0.48",
"@babel/types": "^7.16.0",
"@types/lru-cache": "^5.1.0",
"estree-walker": "^2.0.2",
"magic-string": "^0.25.7",
"pug": "^3.0.1",
"sass": "^1.26.9",
"@vue/consolidate": "^0.17.3",
"hash-sum": "^2.0.0",
"lru-cache": "^5.1.1",
"merge-source-map": "^1.1.0",
"postcss-modules": "^4.0.0",
"postcss-selector-parser": "^6.0.4"
}
}
File renamed without changes.
File renamed without changes.
Expand Up @@ -7,9 +7,15 @@ var packageVersion = require('./package.json').version
if (vueVersion && vueVersion !== packageVersion) {
throw new Error(
'\n\nVue packages version mismatch:\n\n' +
'- vue@' + vueVersion + '\n' +
'- ' + packageName + '@' + packageVersion + '\n\n' +
'This may cause things to work incorrectly. Make sure to use the same version for both.\n'
'- vue@' +
vueVersion +
'\n' +
'- ' +
packageName +
'@' +
packageVersion +
'\n\n' +
'This may cause things to work incorrectly. Make sure to use the same version for both.\n'
)
}

Expand Down
Expand Up @@ -13,6 +13,11 @@
"server",
"ssr"
],
"files": [
"types",
"*.js",
"*.d.ts"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
Expand All @@ -29,7 +34,10 @@
"source-map": "0.5.6"
},
"devDependencies": {
"vue": "file:../.."
"memory-fs": "^0.5.0",
"vue": "file:../..",
"webpack": "^4.46.0",
"file-loader": "^3.0.1"
},
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer#readme"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
import path from 'path'
import webpack from 'webpack'
import MemoryFS from 'memory-fs'
import { RenderOptions } from '../../src/server/create-renderer'
import { RenderOptions } from 'server/create-renderer'
import { createBundleRenderer } from 'web/entry-server-renderer'
import VueSSRServerPlugin from 'server/webpack-plugin/server'

Expand All @@ -20,7 +20,7 @@ export function compileWithWebpack(
},
{
test: /\.(png|woff2|css)$/,
loader: 'file-loader',
loader: require.resolve('file-loader'),
options: {
name: '[name].[ext]'
}
Expand Down Expand Up @@ -62,7 +62,7 @@ export async function createWebpackBundleRenderer(
filename: 'bundle.js',
libraryTarget: 'commonjs2'
},
externals: [require.resolve('../../dist/vue.runtime.common.js')],
externals: [require.resolve('../../../dist/vue.runtime.common.js')],
plugins: asBundle ? [new VueSSRServerPlugin()] : []
})

Expand Down
14 changes: 14 additions & 0 deletions packages/server-renderer/test/fixtures/app.js
@@ -0,0 +1,14 @@
import Vue from '../../../../dist/vue.runtime.common.js'

export default context => {
return new Promise(resolve => {
context.msg = 'hello'
resolve(
new Vue({
render(h) {
return h('div', context.url)
}
})
)
})
}
@@ -1,8 +1,8 @@
module.exports = {
beforeCreate () {
beforeCreate() {
this.$vnode.ssrContext._registeredComponents.add('__MODULE_ID__')
},
render (h) {
render(h) {
return h('div', 'async bar')
}
}
Expand Up @@ -4,10 +4,10 @@ import font from './test.woff2'
import image from './test.png'

export default {
beforeCreate () {
beforeCreate() {
this.$vnode.ssrContext._registeredComponents.add('__MODULE_ID__')
},
render (h) {
render(h) {
return h('div', `async ${font} ${image}`)
}
}
18 changes: 18 additions & 0 deletions packages/server-renderer/test/fixtures/cache-opt-out.js
@@ -0,0 +1,18 @@
import Vue from '../../../../dist/vue.runtime.common.js'

const app = {
name: 'app',
props: ['id'],
serverCacheKey: props => (props.id === 1 ? false : props.id),
render(h) {
return h('div', '/test')
}
}

export default () => {
return Promise.resolve(
new Vue({
render: h => h(app, { props: { id: 1 } })
})
)
}
18 changes: 18 additions & 0 deletions packages/server-renderer/test/fixtures/cache.js
@@ -0,0 +1,18 @@
import Vue from '../../../../dist/vue.runtime.common.js'

const app = {
name: 'app',
props: ['id'],
serverCacheKey: props => props.id,
render(h) {
return h('div', '/test')
}
}

export default () => {
return Promise.resolve(
new Vue({
render: h => h(app, { props: { id: 1 } })
})
)
}
File renamed without changes.

0 comments on commit 9f74f20

Please sign in to comment.