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

Remove Vue 2 support and the .extend method #497

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

Conversation

dwightjack
Copy link
Owner

Drop Vue 2 support

Vue 2 reached End of Life (EOL) on December 31st, 2023. By dropping Vue 2 compatibility we can deliver a smaller package and make the source code more maintainable.

If you're unable to update to Vue 3, please use [email protected]

Removed VueTypes.extend method

VueTypes.extend was deprecated in v5. In v6 this method has been removed. Please migrate your code to use ES6+ extends feature.

Example:

Using VueTypes.extend (old):

import VueTypes from 'vue-types';

export const VueTypesProject = VueTypes.extend([
  {
    name: 'maxLength',
    type: String,
    validator: (max, v) => v.length <= max,
  },
  {
    name: 'positive',
    getter: true,
    type: Number,
    validator: (v) => v > 0,
  },
])

Using ES6+ extends (new):

import VueTypes, { toType } from 'vue-types'

export class VueTypesProject extends VueTypes {
  static maxLength(max) {
    return toType('maxLength', {
      type: String,
      validator: (v) => String(v).length <= max,
    })
  }

  static get positive() {
    return toType('positive', {
      type: Number,
      validator: (v) => v > 0,
    })
  }
}

Package format review:

  • ESM and CJS builds target is ESNext (browsers with support for the latest JavaScript features).
  • UMD builds target is ES2016 (aligned with Vue 3 browser support)

If you're using a bundler, you should not encounter any issue.

If you are directly referencing or importing a specific file in the dist or shim folder, you might need to update its path as described in the following table:

Old (v5) New (v6)
dist/vue-types.m.js dist/index.mjs
dist/vue-types.modern.js dist/index.mjs
dist/vue-types.cjs dist/index.cjs
dist/vue-types.umd.js dist/index.umd.js
dist/shim.m.js dist/shim.mjs
dist/shim.modern.js dist/shim.mjs
dist/shim.cjs dist/shim.cjs
dist/shim.umd.js dist/shim.umd.js
shim/index.m.js dist/shim.mjs
shim/index.modern.js dist/shim.mjs
shim/index.cjs dist/shim.cjs
shim/index.umd.js dist/shim.umd.js

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: c94490e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
vue-types-nuxt Major
vue-types Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Changesets published the following snapshots:

Copy link

cloudflare-workers-and-pages bot commented Dec 12, 2024

Deploying vue-types with  Cloudflare Pages  Cloudflare Pages

Latest commit: c94490e
Status: ✅  Deploy successful!
Preview URL: https://4e60abb3.vue-types.pages.dev
Branch Preview URL: https://vue3-only.vue-types.pages.dev

View logs

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

Successfully merging this pull request may close these issues.

1 participant