Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal]: Deprecate vuepress-vite and vuepress-webpack #1446

Closed
Mister-Hope opened this issue Dec 4, 2023 · 1 comment · Fixed by #1449
Closed

[Proposal]: Deprecate vuepress-vite and vuepress-webpack #1446

Mister-Hope opened this issue Dec 4, 2023 · 1 comment · Fixed by #1449
Assignees

Comments

@Mister-Hope
Copy link
Member

Mister-Hope commented Dec 4, 2023

Clear and concise description of the problem

Useless packages

vuepress-vite and vuepress-webpack are just be used as alias of calling bundler vite/webpack. ( I am not seeing any different use case from downstream. If a user want an advanced usage to "programly call vuepress in scripts", they all choose to import @vuepress/cli and handle the process themselves.

So under this situation I think vuepress-vite and vuepress-webpack are a bit useless as users install them only for the vuepress-vite and vuepress-webpack bin.

Version mismatch

Also users often complains version mismatch. Vue solves this by reexporting pacakges at vue, e.g.: vue/reactivity for @vue/reactivity export, vue/compiler-sfc for @vue/compiler-sfc. We can do this too.

Suggested solution

Currently, if we drop support of yarn1, and only support pnpm>7 npm>8, we can use optionalPeers feature.

This solves the problem that users often triggers a version mismatch with vuepress, and is extactly what vue is doing.

We should deprecate vuepress-vite and vuepress-package, and set @vuepress/bundler-vite and @vuepress/bundler-webpack as optional peers. Also, we can reexport core markdown client shared in vuepress:

{
  "name": "vuepress",
  // ...
  "exports": {
    ".": "./dist/index.js",
    "./bin": "./bin/vuepress.js",
    // a reexport of @vuepress/core
    "./core": "./dist/core.js",
    // a reexport of @vuepress/client
    "./client": "./dist/client.js",
    // a reexport of @vuepress/markdown
    "./markdown": "./dist/markdown.js",
    // a reexport of @vuepress/shared
    "./shared": "./dist/shared.js",
    // a reexport of @vuepress/utils
    "./utils": "./dist/utils.js",
    "./package.json": "./package.json"
  },
  "dependencies": {
    "@vuepress/core": "workspace:*",
    "@vuepress/client": "workspace:*",
    "@vuepress/markdown": "workspace:*",
    "@vuepress/shared": "workspace:*",
    "@vuepress/utils": "workspace:*"
  },
  "peerDependencies": {
    "@vuepress/bundler-vite": "workspace:*",
    "@vuepress/bundler-webpack": "workspace:*",
    "vue": "^3.3.4"
  },
  "peerDependenciesMeta": {
    "@vuepress/bundler-vite": {
      "optional": true
    },
    "@vuepress/bundler-webpack": {
      "optional": true
    },
  }
}

We can then provide try catch to perform bundler detecting/requiring and a new bundler flag if users are missing bundler field.

# when both bundlers are installed and no bundler field in config file
vuepress dev src --bundler vite
vueress dev src --bundler webpack

# use vite by default
vuepress dev src

When users only install 1 bundler, we use that bundler for him.

# automatically use the installed bundler
vuepress dev src

When users install no bundler, we throw an error:

vuepress dev src
❌vuepress: No bundler package found, install @vuepress/bundler-vite or @vuepress/bundler-webpack

The re-export helps avoid the version mismatch problem and simple plugin/theme deps:

// client
import { xxx } from 'vuepress/client';
// node
import { xxx } from 'vuepress/core';
import { xxx } from 'vuepress/utils'
// package.json
{
  "name": "vuepress-plugin-xxx",
  "dependencies": {
    "vuepress": "^2.1.1"
  },
  "peerDependencies": {
    // ensures the user installed one is matching the requirement
    // modern package manager also knows that this means the plugin want to require the same pkg as peer
    "vuepress": "^2.1.1"
  }
}
@meteorlxy
Copy link
Member

This proposal also requires a create helper

meteorlxy added a commit that referenced this issue Dec 27, 2023
)

BREAKING CHANGE: `vuepress-vite` and `vuepress-webpack` packages have been removed, and the corresponding commands have been moved to `vuepress` package. With `vuepress` command, you need to install bundler package and set bundler in config file manually. With `vuepress-vite` and `vuepress-webpack` command, you still need to install bundler package, but you can omit bundler option in config file.

Co-authored-by: meteorlxy <meteor.lxy@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants