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

Make router a separate plugin #4196

Merged
merged 7 commits into from
Jul 5, 2019
Merged

Make router a separate plugin #4196

merged 7 commits into from
Jul 5, 2019

Conversation

pksunkara
Copy link
Contributor

@pksunkara pksunkara commented Jun 25, 2019

Part of #2335. We remove the router option from root options and use it as a plugin as you can see here. This is the actual App.vue template for router which now makes it more consistent over different invoking methods.

id: `core:${name}`,
apply: loadModule(`@vue/cli-service/generator/${name}`, context)
})
if (id === 'router') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if condition will exist until I make the cli-plugin-vuex PR.

@pksunkara
Copy link
Contributor Author

@LinusBorg @sodatea This is ready for review and merge.

@@ -112,15 +105,15 @@ vue add vuex
``` json
{
"useConfigFiles": true,
"router": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though we now have a standalone router plugin, the legacy preset format (router and routerHistoryMode option) can and should still be supported, so as to reduce the migration costs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added support for legacy router option but have it removed from docs completely.

packages/@vue/cli-plugin-router/README.md Show resolved Hide resolved
packages/@vue/cli/lib/util/inferRootOptions.js Outdated Show resolved Hide resolved
@pksunkara
Copy link
Contributor Author

This is now ready for another review.

if (cliOptions.bare) {
preset.plugins['@vue/cli-service'].bare = true
}

// legacy support for router
if (preset.router) {
preset.plugins['@vue/cli-plugin-router'] = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to support routerHistoryMode here.

@@ -10,8 +10,6 @@ const rcPath = exports.rcPath = getRcPath('.vuerc')
const presetSchema = createSchema(joi => joi.object().keys({
bare: joi.boolean(),
useConfigFiles: joi.boolean(),
router: joi.boolean(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though not preferred, they should remain in the schema, otherwise the legacy preset format cannot pass the schema validation.

Note: you may leave a TODO: comment here, once @hapi/joi v16 released, we can update the schema to utilizing its .warn feature. hapijs/joi@59e60aa

@sodatea
Copy link
Member

sodatea commented Jul 4, 2019

As I tested out, the router plugin does not work well with @vue/cli-service 3.x (maybe due to the REPLACE part?).
This may be an issue for users who have global @vue/cli v4.x installed and try to call vue add router on a v3 project. We can add a preflight check in generator/index.js to prompt users the incompatibility.

@pksunkara
Copy link
Contributor Author

As I tested out, the router plugin does not work well with @vue/cli-service 3.x (maybe due to the REPLACE part?).

I wanted to add the assert version stuff we recently added to vue but kinda forgot about it. It fixes this issue.

@pksunkara
Copy link
Contributor Author

Addressed your comments. This is now ready for another review.

@@ -3,9 +3,6 @@ const { toShortPluginId } = require('@vue/cli-shared-utils')

exports.getFeatures = (preset) => {
const features = []
if (preset.router) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't delete this line. It's for displaying preset features.
image

@sodatea
Copy link
Member

sodatea commented Jul 5, 2019

Only 2 small modifications suggested.
The rest of this PR looks great to me.
Thanks for your efforts! 😄

@pksunkara
Copy link
Contributor Author

Updated

@sodatea sodatea merged commit 246ae67 into vuejs:dev Jul 5, 2019
@pksunkara pksunkara deleted the router branch July 5, 2019 15:23
@vue-bot
Copy link

vue-bot commented Jul 5, 2019

Hey @pksunkara, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants