mirror of
https://gitee.com/vuejs/vue.git
synced 2024-11-29 10:37:38 +08:00
refactor: move to monorepo
This commit is contained in:
parent
b3a8ccf3d2
commit
9f74f2048d
37
.github/CONTRIBUTING.md
vendored
37
.github/CONTRIBUTING.md
vendored
@ -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.
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
```
|
||||
|
||||
@ -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.
|
||||
|
||||
- **`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.
|
||||
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`**:
|
||||
|
||||
- `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/).
|
||||
|
||||
@ -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.
|
||||
|
14
.gitignore
vendored
14
.gitignore
vendored
@ -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
|
||||
|
1
compiler-sfc/index.d.ts
vendored
Normal file
1
compiler-sfc/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from '@vue/compiler-sfc'
|
1
compiler-sfc/index.js
Normal file
1
compiler-sfc/index.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('@vue/compiler-sfc')
|
4
compiler-sfc/package.json
Normal file
4
compiler-sfc/package.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts"
|
||||
}
|
38
package.json
38
package.json
@ -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\"",
|
||||
@ -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",
|
||||
@ -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",
|
||||
@ -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": {
|
||||
|
28
packages/compiler-sfc/package.json
Normal file
28
packages/compiler-sfc/package.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
@ -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'
|
||||
)
|
||||
}
|
||||
|
@ -13,6 +13,11 @@
|
||||
"server",
|
||||
"ssr"
|
||||
],
|
||||
"files": [
|
||||
"types",
|
||||
"*.js",
|
||||
"*.d.ts"
|
||||
],
|
||||
"author": "Evan You",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
@ -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"
|
||||
}
|
@ -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'
|
||||
|
||||
@ -20,7 +20,7 @@ export function compileWithWebpack(
|
||||
},
|
||||
{
|
||||
test: /\.(png|woff2|css)$/,
|
||||
loader: 'file-loader',
|
||||
loader: require.resolve('file-loader'),
|
||||
options: {
|
||||
name: '[name].[ext]'
|
||||
}
|
||||
@ -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()] : []
|
||||
})
|
||||
|
14
packages/server-renderer/test/fixtures/app.js
vendored
Normal file
14
packages/server-renderer/test/fixtures/app.js
vendored
Normal file
@ -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')
|
||||
}
|
||||
}
|
@ -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
packages/server-renderer/test/fixtures/cache-opt-out.js
vendored
Normal file
18
packages/server-renderer/test/fixtures/cache-opt-out.js
vendored
Normal file
@ -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
packages/server-renderer/test/fixtures/cache.js
vendored
Normal file
18
packages/server-renderer/test/fixtures/cache.js
vendored
Normal file
@ -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 } })
|
||||
})
|
||||
)
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
import Vue from '../../../dist/vue.runtime.common.js'
|
||||
import Vue from '../../../../dist/vue.runtime.common.js'
|
||||
|
||||
function createRegisterFn (id) {
|
||||
function createRegisterFn(id) {
|
||||
return function (context) {
|
||||
context = context || this.$vnode.ssrContext
|
||||
context.registered.push(id)
|
||||
}
|
||||
}
|
||||
|
||||
function addHooks (comp) {
|
||||
function addHooks(comp) {
|
||||
const hook = createRegisterFn(comp.name)
|
||||
return Object.assign(comp, {
|
||||
_ssrRegister: hook,
|
||||
@ -19,7 +19,7 @@ const grandchild = addHooks({
|
||||
name: 'grandchild',
|
||||
props: ['id'],
|
||||
serverCacheKey: props => props.id,
|
||||
render (h) {
|
||||
render(h) {
|
||||
return h('div', '/test')
|
||||
}
|
||||
})
|
||||
@ -28,8 +28,8 @@ const child = addHooks({
|
||||
name: 'child',
|
||||
props: ['id'],
|
||||
serverCacheKey: props => props.id,
|
||||
render (h) {
|
||||
return h(grandchild, { props: { id: this.id }})
|
||||
render(h) {
|
||||
return h(grandchild, { props: { id: this.id } })
|
||||
}
|
||||
})
|
||||
|
||||
@ -37,13 +37,15 @@ const app = addHooks({
|
||||
name: 'app',
|
||||
props: ['id'],
|
||||
serverCacheKey: props => props.id,
|
||||
render (h) {
|
||||
return h(child, { props: { id: this.id }})
|
||||
render(h) {
|
||||
return h(child, { props: { id: this.id } })
|
||||
}
|
||||
})
|
||||
|
||||
export default () => {
|
||||
return Promise.resolve(new Vue({
|
||||
render: h => h(app, { props: { id: 1 }})
|
||||
}))
|
||||
return Promise.resolve(
|
||||
new Vue({
|
||||
render: h => h(app, { props: { id: 1 } })
|
||||
})
|
||||
)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import Vue from '../../../dist/vue.runtime.common.js'
|
||||
import Vue from '../../../../dist/vue.runtime.common.js'
|
||||
|
||||
// async component!
|
||||
const Foo = () => import('./async-foo')
|
||||
@ -8,11 +8,8 @@ export default context => {
|
||||
return new Promise(resolve => {
|
||||
context.msg = 'hello'
|
||||
const vm = new Vue({
|
||||
render (h) {
|
||||
return h('div', [
|
||||
context.url,
|
||||
h(Foo)
|
||||
])
|
||||
render(h) {
|
||||
return h('div', [context.url, h(Foo)])
|
||||
}
|
||||
})
|
||||
|
@ -1,6 +1,5 @@
|
||||
// @vitest-environment node
|
||||
|
||||
import LRU from 'lru-cache'
|
||||
import { createWebpackBundleRenderer } from './compile-with-webpack'
|
||||
|
||||
describe('SSR: bundle renderer', () => {
|
||||
@ -171,7 +170,7 @@ function createAssertions(runInNewContext) {
|
||||
})
|
||||
|
||||
it('render with cache (nested)', async () => {
|
||||
const cache = new LRU({ ttl: 65535 }) as any
|
||||
const cache = new Map() as any
|
||||
vi.spyOn(cache, 'get')
|
||||
vi.spyOn(cache, 'set')
|
||||
const options = {
|
||||
@ -284,7 +283,7 @@ function createAssertions(runInNewContext) {
|
||||
try {
|
||||
await renderer.renderToString()
|
||||
} catch (err: any) {
|
||||
expect(err.stack).toContain('test/ssr/fixtures/error.js:1:0')
|
||||
expect(err.stack).toContain('server-renderer/test/fixtures/error.js:1:0')
|
||||
expect(err.message).toBe('foo')
|
||||
}
|
||||
})
|
||||
@ -300,7 +299,7 @@ function createAssertions(runInNewContext) {
|
||||
stream.on('error', resolve)
|
||||
})
|
||||
|
||||
expect(err.stack).toContain('test/ssr/fixtures/error.js:1:0')
|
||||
expect(err.stack).toContain('server-renderer/test/fixtures/error.js:1:0')
|
||||
expect(err.message).toBe('foo')
|
||||
})
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
} from './compile-with-webpack'
|
||||
import { createRenderer } from 'web/entry-server-renderer'
|
||||
import VueSSRClientPlugin from 'server/webpack-plugin/client'
|
||||
import { RenderOptions } from '../../src/server/create-renderer'
|
||||
import { RenderOptions } from 'server/create-renderer'
|
||||
|
||||
const defaultTemplate = `<html><head></head><body><!--vue-ssr-outlet--></body></html>`
|
||||
const interpolateTemplate = `<html><head><title>{{ title }}</title></head><body><!--vue-ssr-outlet-->{{{ snippet }}}</body></html>`
|
37
packages/server-renderer/tsconfig.json
Normal file
37
packages/server-renderer/tsconfig.json
Normal file
@ -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/*"],
|
||||
"sfc/*": ["../../src/sfc/*"],
|
||||
"shared/*": ["../../src/shared/*"],
|
||||
"web/*": ["../../src/platforms/web/*"],
|
||||
"v3": ["../../src/v3/index"],
|
||||
"v3/*": ["../../src/v3/*"],
|
||||
"typescript/*": ["../../typescript/*"],
|
||||
"vue": ["../../src/platforms/web/entry-runtime-with-compiler"]
|
||||
}
|
||||
},
|
||||
"include": ["../../src", "../../typescript", "../../test/test-env.d.ts", "."]
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
@ -9,9 +9,5 @@
|
||||
"vue": ["../../../types/index.d.ts"]
|
||||
}
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"../../../types"
|
||||
]
|
||||
"include": ["**/*.ts", "../../../types"]
|
||||
}
|
9337
packages/template-compiler/browser.js
Normal file
9337
packages/template-compiler/browser.js
Normal file
File diff suppressed because one or more lines are too long
5148
packages/template-compiler/build.js
Normal file
5148
packages/template-compiler/build.js
Normal file
File diff suppressed because it is too large
Load Diff
32
packages/template-compiler/index.js
Normal file
32
packages/template-compiler/index.js
Normal file
@ -0,0 +1,32 @@
|
||||
try {
|
||||
var vueVersion = require('vue').version
|
||||
} catch (e) {}
|
||||
|
||||
var packageName = require('./package.json').name
|
||||
var packageVersion = require('./package.json').version
|
||||
if (vueVersion && vueVersion !== packageVersion) {
|
||||
var vuePath = require.resolve('vue')
|
||||
var packagePath = require.resolve('./package.json')
|
||||
throw new Error(
|
||||
'\n\nVue packages version mismatch:\n\n' +
|
||||
'- vue@' +
|
||||
vueVersion +
|
||||
' (' +
|
||||
vuePath +
|
||||
')\n' +
|
||||
'- ' +
|
||||
packageName +
|
||||
'@' +
|
||||
packageVersion +
|
||||
' (' +
|
||||
packagePath +
|
||||
')\n\n' +
|
||||
'This may cause things to work incorrectly. Make sure to use the same version for both.\n' +
|
||||
'If you are using vue-loader@>=10.0, simply update vue-template-compiler.\n' +
|
||||
'If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump ' +
|
||||
packageName +
|
||||
' to the latest.\n'
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = require('./build')
|
@ -1,4 +1,4 @@
|
||||
import Vue, { VNode } from 'vue'
|
||||
import { VNode } from 'vue'
|
||||
|
||||
/*
|
||||
* Template compilation options / results
|
@ -6,7 +6,7 @@ import {
|
||||
ssrCompileToFunctions,
|
||||
parseComponent,
|
||||
generateCodeFrame
|
||||
} from './'
|
||||
} from '.'
|
||||
|
||||
// check compile options
|
||||
const compiled = compile('<div>hi</div>', {
|
13
packages/template-compiler/types/tsconfig.json
Normal file
13
packages/template-compiler/types/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"paths": {
|
||||
"vue": ["../../../types/index.d.ts"]
|
||||
}
|
||||
},
|
||||
"include": ["**/*.ts", "../../../types"]
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
try {
|
||||
var vueVersion = require('vue').version
|
||||
} catch (e) {}
|
||||
|
||||
var packageName = require('./package.json').name
|
||||
var packageVersion = require('./package.json').version
|
||||
if (vueVersion && vueVersion !== packageVersion) {
|
||||
var vuePath = require.resolve('vue')
|
||||
var packagePath = require.resolve('./package.json')
|
||||
throw new Error(
|
||||
'\n\nVue packages version mismatch:\n\n' +
|
||||
'- vue@' + vueVersion + ' (' + vuePath + ')\n' +
|
||||
'- ' + packageName + '@' + packageVersion + ' (' + packagePath + ')\n\n' +
|
||||
'This may cause things to work incorrectly. Make sure to use the same version for both.\n' +
|
||||
'If you are using vue-loader@>=10.0, simply update vue-template-compiler.\n' +
|
||||
'If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump ' + packageName + ' to the latest.\n'
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = require('./build')
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
]
|
||||
}
|
1218
pnpm-lock.yaml
1218
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
- 'packages/*'
|
@ -8,6 +8,6 @@ module.exports = {
|
||||
core: resolve('src/core'),
|
||||
shared: resolve('src/shared'),
|
||||
web: resolve('src/platforms/web'),
|
||||
server: resolve('src/server'),
|
||||
server: resolve('packages/server-renderer/src'),
|
||||
sfc: resolve('src/sfc')
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ const resolve = p => {
|
||||
|
||||
const builds = {
|
||||
// Runtime only (CommonJS). Used by bundlers e.g. Webpack & Browserify
|
||||
'web-runtime-cjs-dev': {
|
||||
'runtime-cjs-dev': {
|
||||
entry: resolve('web/entry-runtime.ts'),
|
||||
dest: resolve('dist/vue.runtime.common.dev.js'),
|
||||
format: 'cjs',
|
||||
env: 'development',
|
||||
banner
|
||||
},
|
||||
'web-runtime-cjs-prod': {
|
||||
'runtime-cjs-prod': {
|
||||
entry: resolve('web/entry-runtime.ts'),
|
||||
dest: resolve('dist/vue.runtime.common.prod.js'),
|
||||
format: 'cjs',
|
||||
@ -42,7 +42,7 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// Runtime+compiler CommonJS build (CommonJS)
|
||||
'web-full-cjs-dev': {
|
||||
'full-cjs-dev': {
|
||||
entry: resolve('web/entry-runtime-with-compiler.ts'),
|
||||
dest: resolve('dist/vue.common.dev.js'),
|
||||
format: 'cjs',
|
||||
@ -50,7 +50,7 @@ const builds = {
|
||||
alias: { he: './entity-decoder' },
|
||||
banner
|
||||
},
|
||||
'web-full-cjs-prod': {
|
||||
'full-cjs-prod': {
|
||||
entry: resolve('web/entry-runtime-with-compiler.ts'),
|
||||
dest: resolve('dist/vue.common.prod.js'),
|
||||
format: 'cjs',
|
||||
@ -59,14 +59,14 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// Runtime only ES modules build (for bundlers)
|
||||
'web-runtime-esm': {
|
||||
'runtime-esm': {
|
||||
entry: resolve('web/entry-runtime-esm.ts'),
|
||||
dest: resolve('dist/vue.runtime.esm.js'),
|
||||
format: 'es',
|
||||
banner
|
||||
},
|
||||
// Runtime+compiler ES modules build (for bundlers)
|
||||
'web-full-esm': {
|
||||
'full-esm': {
|
||||
entry: resolve('web/entry-runtime-with-compiler-esm.ts'),
|
||||
dest: resolve('dist/vue.esm.js'),
|
||||
format: 'es',
|
||||
@ -74,7 +74,7 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// Runtime+compiler ES modules build (for direct import in browser)
|
||||
'web-full-esm-browser-dev': {
|
||||
'full-esm-browser-dev': {
|
||||
entry: resolve('web/entry-runtime-with-compiler-esm.ts'),
|
||||
dest: resolve('dist/vue.esm.browser.js'),
|
||||
format: 'es',
|
||||
@ -84,7 +84,7 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// Runtime+compiler ES modules build (for direct import in browser)
|
||||
'web-full-esm-browser-prod': {
|
||||
'full-esm-browser-prod': {
|
||||
entry: resolve('web/entry-runtime-with-compiler-esm.ts'),
|
||||
dest: resolve('dist/vue.esm.browser.min.js'),
|
||||
format: 'es',
|
||||
@ -94,7 +94,7 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// runtime-only build (Browser)
|
||||
'web-runtime-dev': {
|
||||
'runtime-dev': {
|
||||
entry: resolve('web/entry-runtime.ts'),
|
||||
dest: resolve('dist/vue.runtime.js'),
|
||||
format: 'umd',
|
||||
@ -102,7 +102,7 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// runtime-only production build (Browser)
|
||||
'web-runtime-prod': {
|
||||
'runtime-prod': {
|
||||
entry: resolve('web/entry-runtime.ts'),
|
||||
dest: resolve('dist/vue.runtime.min.js'),
|
||||
format: 'umd',
|
||||
@ -110,7 +110,7 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// Runtime+compiler development build (Browser)
|
||||
'web-full-dev': {
|
||||
'full-dev': {
|
||||
entry: resolve('web/entry-runtime-with-compiler.ts'),
|
||||
dest: resolve('dist/vue.js'),
|
||||
format: 'umd',
|
||||
@ -119,7 +119,7 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// Runtime+compiler production build (Browser)
|
||||
'web-full-prod': {
|
||||
'full-prod': {
|
||||
entry: resolve('web/entry-runtime-with-compiler.ts'),
|
||||
dest: resolve('dist/vue.min.js'),
|
||||
format: 'umd',
|
||||
@ -128,70 +128,78 @@ const builds = {
|
||||
banner
|
||||
},
|
||||
// Web compiler (CommonJS).
|
||||
'web-compiler': {
|
||||
compiler: {
|
||||
entry: resolve('web/entry-compiler.ts'),
|
||||
dest: resolve('packages/vue-template-compiler/build.js'),
|
||||
dest: resolve('packages/template-compiler/build.js'),
|
||||
format: 'cjs',
|
||||
external: Object.keys(
|
||||
require('../packages/vue-template-compiler/package.json').dependencies
|
||||
require('../packages/template-compiler/package.json').dependencies
|
||||
)
|
||||
},
|
||||
// Web compiler (UMD for in-browser use).
|
||||
'web-compiler-browser': {
|
||||
'compiler-browser': {
|
||||
entry: resolve('web/entry-compiler.ts'),
|
||||
dest: resolve('packages/vue-template-compiler/browser.js'),
|
||||
dest: resolve('packages/template-compiler/browser.js'),
|
||||
format: 'umd',
|
||||
env: 'development',
|
||||
moduleName: 'VueTemplateCompiler',
|
||||
plugins: [node(), cjs()]
|
||||
},
|
||||
// Web server renderer (CommonJS).
|
||||
'web-server-renderer-dev': {
|
||||
'server-renderer-dev': {
|
||||
entry: resolve('web/entry-server-renderer.ts'),
|
||||
dest: resolve('packages/vue-server-renderer/build.dev.js'),
|
||||
dest: resolve('packages/server-renderer/build.dev.js'),
|
||||
format: 'cjs',
|
||||
env: 'development',
|
||||
external: [
|
||||
'stream',
|
||||
...Object.keys(
|
||||
require('../packages/vue-server-renderer/package.json').dependencies
|
||||
require('../packages/server-renderer/package.json').dependencies
|
||||
)
|
||||
]
|
||||
},
|
||||
'web-server-renderer-prod': {
|
||||
'server-renderer-prod': {
|
||||
entry: resolve('web/entry-server-renderer.ts'),
|
||||
dest: resolve('packages/vue-server-renderer/build.prod.js'),
|
||||
dest: resolve('packages/server-renderer/build.prod.js'),
|
||||
format: 'cjs',
|
||||
env: 'production',
|
||||
external: [
|
||||
'stream',
|
||||
...Object.keys(
|
||||
require('../packages/vue-server-renderer/package.json').dependencies
|
||||
require('../packages/server-renderer/package.json').dependencies
|
||||
)
|
||||
]
|
||||
},
|
||||
'web-server-renderer-basic': {
|
||||
'server-renderer-basic': {
|
||||
entry: resolve('web/entry-server-basic-renderer.ts'),
|
||||
dest: resolve('packages/vue-server-renderer/basic.js'),
|
||||
dest: resolve('packages/server-renderer/basic.js'),
|
||||
format: 'umd',
|
||||
env: 'development',
|
||||
moduleName: 'renderVueComponentToString',
|
||||
plugins: [node(), cjs()]
|
||||
},
|
||||
'web-server-renderer-webpack-server-plugin': {
|
||||
'server-renderer-webpack-server-plugin': {
|
||||
entry: resolve('server/webpack-plugin/server.ts'),
|
||||
dest: resolve('packages/vue-server-renderer/server-plugin.js'),
|
||||
dest: resolve('packages/server-renderer/server-plugin.js'),
|
||||
format: 'cjs',
|
||||
external: Object.keys(
|
||||
require('../packages/vue-server-renderer/package.json').dependencies
|
||||
require('../packages/server-renderer/package.json').dependencies
|
||||
)
|
||||
},
|
||||
'web-server-renderer-webpack-client-plugin': {
|
||||
'server-renderer-webpack-client-plugin': {
|
||||
entry: resolve('server/webpack-plugin/client.ts'),
|
||||
dest: resolve('packages/vue-server-renderer/client-plugin.js'),
|
||||
dest: resolve('packages/server-renderer/client-plugin.js'),
|
||||
format: 'cjs',
|
||||
external: Object.keys(
|
||||
require('../packages/vue-server-renderer/package.json').dependencies
|
||||
require('../packages/server-renderer/package.json').dependencies
|
||||
)
|
||||
},
|
||||
'compiler-sfc': {
|
||||
entry: resolve('web/entry-compiler-sfc.ts'),
|
||||
dest: resolve('packages/compiler-sfc/dist/compiler-sfc.js'),
|
||||
format: 'cjs',
|
||||
external: Object.keys(
|
||||
require('../packages/compiler-sfc/package.json').dependencies
|
||||
)
|
||||
}
|
||||
}
|
||||
|
1
src/platforms/web/entry-compiler-sfc.ts
Normal file
1
src/platforms/web/entry-compiler-sfc.ts
Normal file
@ -0,0 +1 @@
|
||||
export function compile() {}
|
@ -6,7 +6,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<script src="../../dist/vue.min.js"></script>
|
||||
<script src="../../packages/vue-server-renderer/basic.js"></script>
|
||||
<script src="../../packages/server-renderer/basic.js"></script>
|
||||
|
||||
<div id="result">wtf</div>
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
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,16 +0,0 @@
|
||||
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 }})
|
||||
}))
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
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 }})
|
||||
}))
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
"paths": {
|
||||
"compiler/*": ["../src/compiler/*"],
|
||||
"core/*": ["../src/core/*"],
|
||||
"server/*": ["../src/server/*"],
|
||||
"server/*": ["../packages/server-renderer/src/*"],
|
||||
"sfc/*": ["../src/sfc/*"],
|
||||
"shared/*": ["../src/shared/*"],
|
||||
"web/*": ["../src/platforms/web/*"],
|
||||
|
@ -23,7 +23,7 @@
|
||||
"paths": {
|
||||
"compiler/*": ["src/compiler/*"],
|
||||
"core/*": ["src/core/*"],
|
||||
"server/*": ["src/server/*"],
|
||||
"server/*": ["packages/server-renderer/src/*"],
|
||||
"sfc/*": ["src/sfc/*"],
|
||||
"shared/*": ["src/shared/*"],
|
||||
"web/*": ["src/platforms/web/*"],
|
||||
@ -32,5 +32,5 @@
|
||||
"vue": ["src/platforms/web/entry-runtime-with-compiler"]
|
||||
}
|
||||
},
|
||||
"include": ["src", "typescript"],
|
||||
"include": ["src", "typescript", "packages/server-renderer/server"],
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ export default defineConfig({
|
||||
alias: {
|
||||
compiler: resolve('src/compiler'),
|
||||
core: resolve('src/core'),
|
||||
server: resolve('src/server'),
|
||||
server: resolve('packages/server-renderer/src'),
|
||||
sfc: resolve('src/sfc'),
|
||||
shared: resolve('src/shared'),
|
||||
web: resolve('src/platforms/web'),
|
||||
|
Loading…
Reference in New Issue
Block a user