diff --git a/.github/contributing.md b/.github/contributing.md index 122cf0e0..f1656ce4 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -185,16 +185,7 @@ This repository employs a [monorepo](https://en.wikipedia.org/wiki/Monorepo) set A [live version](https://vue-next-template-explorer.netlify.com) of the template explorer is also available, which can be used for providing reproductions for compiler bugs. You can also pick the deployment for a specific commit from the [deploy logs](https://app.netlify.com/sites/vue-next-template-explorer/deploys). -- `shared`: **Private.** Utilities shared across multiple packages (especially by both runtime and compiler packages). This package is private and not published. Instead, it is **inlined** into the package that imports it during build. - - - **Note:** if re-exporting a function from `@vue/shared` as a public API, it is necessary to re-define its type before exporting so that the final `d.ts` doesn't attempt to import `@vue/shared`, e.g.: - - ```ts - import { foo } from '@vue/shared' - export const publicFoo = foo as { - /* re-define type */ - } - ``` +- `shared`: Internal utilities shared across multiple packages (especially environment-agnostic utils used by both runtime and compiler packages). - `vue`: The public facing "full build" which includes both the runtime AND the compiler. diff --git a/package.json b/package.json index 82e828a0..8479807c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "size": "node scripts/build.js vue runtime-dom size-check -p -f global", "lint": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"", "test": "node scripts/build.js vue -f global -d && jest", - "test-dts": "node scripts/build.js reactivity runtime-core runtime-dom -dt -f esm-bundler && tsd", + "test-dts": "node scripts/build.js shared reactivity runtime-core runtime-dom -dt -f esm-bundler && tsd", "release": "node scripts/release.js", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "dev-compiler": "npm-run-all --parallel \"dev template-explorer\" serve", diff --git a/packages/compiler-core/package.json b/packages/compiler-core/package.json index e11b6e1b..b2454497 100644 --- a/packages/compiler-core/package.json +++ b/packages/compiler-core/package.json @@ -18,7 +18,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -26,10 +26,11 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-core#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-core#readme", "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@babel/parser": "^7.8.6", "@babel/types": "^7.8.6", "estree-walker": "^0.8.1", diff --git a/packages/compiler-core/src/index.ts b/packages/compiler-core/src/index.ts index 6a224eb4..0cb41d11 100644 --- a/packages/compiler-core/src/index.ts +++ b/packages/compiler-core/src/index.ts @@ -50,12 +50,4 @@ export { } from './transforms/vSlot' export { resolveComponentType, buildProps } from './transforms/transformElement' export { processSlotOutlet } from './transforms/transformSlotOutlet' - -// utility, but need to rewrite typing to avoid dts relying on @vue/shared -import { generateCodeFrame as _genCodeFrame } from '@vue/shared' -const generateCodeFrame = _genCodeFrame as ( - source: string, - start?: number, - end?: number -) => string -export { generateCodeFrame } +export { generateCodeFrame } from '@vue/shared' diff --git a/packages/compiler-dom/package.json b/packages/compiler-dom/package.json index 4b023e1c..01c77ea2 100644 --- a/packages/compiler-dom/package.json +++ b/packages/compiler-dom/package.json @@ -22,7 +22,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -30,10 +30,11 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-dom#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-dom#readme", "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/compiler-core": "3.0.0-alpha.7" } } diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index 65eecf41..0dff6d43 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -15,7 +15,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -23,13 +23,14 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-sfc#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-sfc#readme", "peerDependencies": { "vue": "3.0.0-alpha.7" }, "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/compiler-core": "3.0.0-alpha.7", "@vue/compiler-dom": "3.0.0-alpha.7", "consolidate": "^0.15.1", diff --git a/packages/compiler-ssr/package.json b/packages/compiler-ssr/package.json index 61783137..aa3f289b 100644 --- a/packages/compiler-ssr/package.json +++ b/packages/compiler-ssr/package.json @@ -15,7 +15,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -23,10 +23,11 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-ssr#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-ssr#readme", "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/compiler-dom": "3.0.0-alpha.7" } } diff --git a/packages/reactivity/package.json b/packages/reactivity/package.json index badcfd5e..accdade4 100644 --- a/packages/reactivity/package.json +++ b/packages/reactivity/package.json @@ -13,7 +13,7 @@ "sideEffects": false, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "buildOptions": { "name": "VueReactivity", @@ -30,7 +30,10 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/reactivity#readme" + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/reactivity#readme", + "dependencies": { + "@vue/shared": "3.0.0-alpha.7" + } } diff --git a/packages/runtime-core/package.json b/packages/runtime-core/package.json index fc3f378f..dd680659 100644 --- a/packages/runtime-core/package.json +++ b/packages/runtime-core/package.json @@ -19,7 +19,7 @@ "sideEffects": false, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -27,10 +27,11 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-core#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/runtime-core#readme", "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/reactivity": "3.0.0-alpha.7" } } diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 4e9459d4..d0b8444a 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -101,15 +101,7 @@ export { createCommentVNode, createStaticVNode } from './vnode' -// Since @vue/shared is inlined into final builds, -// when re-exporting from @vue/shared we need to avoid relying on their original -// types so that the bundled d.ts does not attempt to import from it. -import { - toDisplayString as _toDisplayString, - camelize as _camelize -} from '@vue/shared' -export const toDisplayString = _toDisplayString as (s: unknown) => string -export const camelize = _camelize as (s: string) => string +export { toDisplayString, camelize } from '@vue/shared' // For integration with runtime compiler export { registerRuntimeCompiler } from './component' diff --git a/packages/runtime-dom/package.json b/packages/runtime-dom/package.json index 5cad71b1..04b37986 100644 --- a/packages/runtime-dom/package.json +++ b/packages/runtime-dom/package.json @@ -25,7 +25,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -33,10 +33,11 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-dom#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/runtime-dom#readme", "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/runtime-core": "3.0.0-alpha.7", "csstype": "^2.6.8" } diff --git a/packages/runtime-test/package.json b/packages/runtime-test/package.json index c6a6a368..91ae6ea9 100644 --- a/packages/runtime-test/package.json +++ b/packages/runtime-test/package.json @@ -12,7 +12,7 @@ ], "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "buildOptions": { "name": "VueRuntimeTest", @@ -26,10 +26,11 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/runtime-test#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/runtime-test#readme", "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/runtime-core": "3.0.0-alpha.7" } } diff --git a/packages/server-renderer/package.json b/packages/server-renderer/package.json index ca5719e4..7a7f795d 100644 --- a/packages/server-renderer/package.json +++ b/packages/server-renderer/package.json @@ -15,7 +15,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -23,13 +23,14 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/server-renderer#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/server-renderer#readme", "peerDependencies": { "vue": "3.0.0-alpha.7" }, "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/compiler-ssr": "3.0.0-alpha.7" } } diff --git a/packages/shared/api-extractor.json b/packages/shared/api-extractor.json new file mode 100644 index 00000000..d182b70f --- /dev/null +++ b/packages/shared/api-extractor.json @@ -0,0 +1,7 @@ +{ + "extends": "../../api-extractor.json", + "mainEntryPointFilePath": "./dist/packages//src/index.d.ts", + "dtsRollup": { + "untrimmedFilePath": "./dist/.d.ts" + } +} diff --git a/packages/shared/index.js b/packages/shared/index.js new file mode 100644 index 00000000..a2ee43e3 --- /dev/null +++ b/packages/shared/index.js @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/shared.cjs.prod.js') +} else { + module.exports = require('./dist/shared.cjs.js') +} diff --git a/packages/shared/package.json b/packages/shared/package.json index 2fa7c446..eca54142 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,5 +1,31 @@ { "name": "@vue/shared", "version": "3.0.0-alpha.7", - "private": true + "description": "internal utils shared across @vue packages", + "main": "index.js", + "module": "dist/shared.esm-bundler.js", + "types": "dist/shared.d.ts", + "files": [ + "index.js", + "dist" + ], + "buildOptions": { + "formats": [ + "esm-bundler", + "cjs" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/vuejs/vue-next.git" + }, + "keywords": [ + "vue" + ], + "author": "Evan You", + "license": "MIT", + "bugs": { + "url": "https://github.com/vuejs/vue-next/issues" + }, + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/shared#readme" } diff --git a/packages/vue/package.json b/packages/vue/package.json index 30c9a03c..720b2585 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -24,7 +24,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/vuejs/vue.git" + "url": "git+https://github.com/vuejs/vue-next.git" }, "keywords": [ "vue" @@ -32,10 +32,11 @@ "author": "Evan You", "license": "MIT", "bugs": { - "url": "https://github.com/vuejs/vue/issues" + "url": "https://github.com/vuejs/vue-next/issues" }, - "homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue#readme", + "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/vue#readme", "dependencies": { + "@vue/shared": "3.0.0-alpha.7", "@vue/compiler-dom": "3.0.0-alpha.7", "@vue/runtime-dom": "3.0.0-alpha.7" }, diff --git a/rollup.config.js b/rollup.config.js index b5150fdc..46f3d3fc 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,4 +1,3 @@ -import fs from 'fs' import path from 'path' import ts from 'rollup-plugin-typescript2' import replace from '@rollup/plugin-replace' @@ -16,10 +15,6 @@ const resolve = p => path.resolve(packageDir, p) const pkg = require(resolve(`package.json`)) const packageOptions = pkg.buildOptions || {} -const knownExternals = fs.readdirSync(packagesDir).filter(p => { - return p !== '@vue/shared' -}) - // ensure TS checks only once for each build let hasTSChecked = false @@ -112,9 +107,7 @@ function createConfig(format, output, plugins = []) { format === 'esm-bundler-runtime' ? `src/runtime.ts` : `src/index.ts` const external = - isGlobalBuild || isRawESMBuild - ? [] - : knownExternals.concat(Object.keys(pkg.dependencies || [])) + isGlobalBuild || isRawESMBuild ? [] : Object.keys(pkg.dependencies || {}) const nodePlugins = packageOptions.enableNonBrowserBranches ? [