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

feat!: drop CJS and use VueUse v13 #254

Merged
merged 21 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4

- run: corepack enable
- run: npm i -fg corepack && corepack enable

- uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v4

- name: Enable corepack
run: corepack enable
run: npm i -fg corepack && corepack enable

- name: Setup node
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0

- name: Enable corepack
run: corepack enable
run: npm i -fg corepack && corepack enable

- name: Setup node.js
uses: actions/setup-node@v4
Expand Down
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

9 changes: 1 addition & 8 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
rollup: {
emitCJS: true,
emitCJS: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

remove rollup entry, and change declaration to node16

},
declaration: true,
// warnings triggered by nuxt exports not being built - happens in separate script
Expand All @@ -16,13 +16,6 @@ export default defineBuildConfig({
format: 'esm',
ext: 'mjs',
},
{
input: 'src/index.ts',
outDir: 'dist',
name: 'index',
format: 'cjs',
ext: 'cjs',
},
],
externals: [
'@nuxt/kit',
Expand Down
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
"import": "./dist/index.mjs"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

use ".": "./dist/index.mjs"

"./nuxt": {
"import": "./dist/nuxt/module.mjs",
"require": "./dist/nuxt/module.cjs"
"import": "./dist/nuxt/module.mjs"
Copy link
Contributor

Choose a reason for hiding this comment

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

use "./nuxt": "./dist/module.mjs"

}
},
"main": "./dist/index.cjs",
Copy link
Contributor

@userquin userquin Mar 10, 2025

Choose a reason for hiding this comment

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

add the main entry using "main": "./dist/index.mjs",

"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

use "types": "./dist/index.d.mts",

"typesVersions": {
Copy link
Contributor

@userquin userquin Mar 10, 2025

Choose a reason for hiding this comment

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

since we're not using .js in the file extensions in the package, we need to add the d.mts for nuxt , "./*" isn't effective:

"typesVersions": {
  "*": {
    "nuxt": [
      "./dist/nuxt/module.d.mts"
    ]
  }
}

Copy link
Member

Choose a reason for hiding this comment

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

So should we have the following?

  "typesVersions": {
    "*": {
      "*": [
        "./dist/*",
        "./*"
      ],
      "nuxt": [
        "./dist/nuxt/module.d.mts"
      ]
    }
  },

Copy link
Contributor

Choose a reason for hiding this comment

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

or just use .js instead .mjs and keep current "typesVersions"

Copy link
Contributor

Choose a reason for hiding this comment

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

So should we have the following?

  "typesVersions": {
    "*": {
      "*": [
        "./dist/*",
        "./*"
      ],
      "nuxt": [
        "./dist/nuxt/module.d.mts"
      ]
    }
  },

no, just nuxt entry

Copy link
Contributor

Choose a reason for hiding this comment

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

in fact Nuxt will drop support for node10 module resolution (if not yet removed), we can remove "typesVersions" entry

Copy link
Contributor

Choose a reason for hiding this comment

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

Nuxt still supports node 10 , so it is fine

Expand Down Expand Up @@ -79,8 +76,8 @@
"vue": ">=3.0.0"
},
"dependencies": {
"@vueuse/core": "^10.10.0",
"@vueuse/shared": "^10.10.0",
"@vueuse/core": "^13.0.0",
"@vueuse/shared": "^13.0.0",
"csstype": "^3.1.3",
"framesync": "^6.1.2",
"popmotion": "^11.0.5",
Expand All @@ -106,7 +103,6 @@
"lint-staged": "^15.2.5",
"nuxt": "^3.13.0",
"pkg-pr-new": "^0.0.20",
"prettier": "^3.2.5",
"typescript": "^5.4.5",
"unbuild": "^2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

we should also update typescript and unbuild versions

"vite": "5.2.12",
Expand Down
125 changes: 113 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions scripts/fix-nuxt-build.mjs

This file was deleted.

6 changes: 5 additions & 1 deletion src/directive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export function directive<T extends string>(
const motionOptions = { eventListeners: true, lifeCycleHooks: true, syncVariants: true, visibilityHooks: false }

// Create motion instance
const motionInstance = useMotion(el, variantsRef, motionOptions)
const motionInstance = useMotion(
el,
variantsRef as MotionVariants<T>,
motionOptions,
)

// Pass the motion instance via the local element
// @ts-expect-error - we know that the element is a HTMLElement
Expand Down
2 changes: 1 addition & 1 deletion src/useMotionControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function useMotionControls<T extends string, V extends MotionVariants<T>>
{ motionValues, push, stop }: MotionTransitions = useMotionTransitions(),
): MotionControls<T, V> {
// Variants as ref
const _variants = unref(variants)
const _variants = unref(variants) as V

// Is the current instance animated ref
const isAnimating = ref(false)
Expand Down
Loading
Loading