-
Notifications
You must be signed in to change notification settings - Fork 342
feat!: move package to ESM only #1078
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
base: main
Are you sure you want to change the base?
Changes from all commits
988967b
edb07a4
6c6c831
f69dcb0
aed7f91
7bd44b3
fd1c924
14ab05a
a161641
be6d967
779a6a9
5c6d957
757ff79
e8e2237
824e294
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules/ | |
npm-debug.log | ||
coverage/ | ||
dist/ | ||
.idea/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<script lang="ts"> | ||
// | ||
</script> | ||
<template> | ||
<h1>VTooltip Demo 1</h1> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "@vue/tsconfig/tsconfig.dom.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", | ||
|
||
"baseUrl": ".", | ||
"paths": { | ||
"floating-vue/directives": ["../packages/floating-vue/src/directives.ts"], | ||
"floating-vue": ["../packages/floating-vue/src/index.ts"] | ||
} | ||
}, | ||
"include": ["*.d.ts", "src/**/*", "src/**/*.vue"], | ||
"exclude": ["src/**/__tests__/*"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.node.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.app.json" | ||
} | ||
], | ||
"files": [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"extends": "@tsconfig/node22/tsconfig.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", | ||
|
||
"baseUrl": ".", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"types": ["node"], | ||
"paths": { | ||
"floating-vue/directives": ["../packages/floating-vue/src/directives.ts"], | ||
"floating-vue": ["../packages/floating-vue/src/index.ts"] | ||
}, | ||
"noEmit": true | ||
}, | ||
"include": [ | ||
"vite.config.*", | ||
"vitest.config.*", | ||
"cypress.config.*", | ||
"nightwatch.conf.*", | ||
"playwright.config.*" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
import AutoImport from 'unplugin-auto-import/vite' | ||
import { FloatingVueDirectives } from 'floating-vue/unimport-presets' | ||
import { resolve } from 'node:path' | ||
|
||
export default defineConfig({ | ||
resolve: { | ||
alias: { | ||
'floating-vue/style.css': resolve('./node_modules/floating-vue/dist/style.css'), | ||
'floating-vue/dist/style.css': resolve('./node_modules/floating-vue/dist/style.css'), | ||
'floating-vue/components': resolve('./node_modules/floating-vue/components.mjs'), | ||
'floating-vue/directives': resolve('./node_modules/floating-vue/directives.mjs'), | ||
'floating-vue': resolve('./node_modules/floating-vue/dist/index.mjs'), | ||
userquin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}, | ||
define: { | ||
'VERSION': JSON.stringify('0.0.0'), | ||
}, | ||
plugins: [ | ||
vue(), | ||
AutoImport({ | ||
imports: [ | ||
FloatingVueDirectives(), | ||
], | ||
dts: true, | ||
vueDirectives: true, | ||
}) | ||
], | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export { VDropdown, VMenu, VTooltip } from './dist/components.mjs' | ||
export { Placement } from './dist/utils.mjs' | ||
export { TriggerEvent } from './dist/components/PopperWrapper.vue.mjs' | ||
export { hideAllPoppers, recomputeAllPoppers } from './dist/components/Popper.mjs' | ||
|
||
export { default as Popper } from './dist/components/Popper.vue.mjs' | ||
export { default as PopperContent } from './dist/components/PopperContent.vue.mjs' | ||
export { default as PopperMethods } from './dist/components/PopperMethods.mjs' | ||
export { default as PopperWrapper } from './dist/components/PopperWrapper.vue.mjs' | ||
export { default as ThemeClass } from './dist/components/ThemeClass.mjs' | ||
export { default as Tooltip } from './dist/components/Tooltip.mjs' | ||
export { default as TooltipDirective } from './dist/components/TooltipDirective.vue.mjs' | ||
|
||
export declare const ComponentNames: readonly ['VDropdown' | 'VMenu' | 'VTooltip' | 'Popper' | 'PopperContent' | 'PopperMethods' | 'PopperWrapper' | 'ThemeClass' | 'Tooltip' | 'TooltipDirective']; | ||
export type ComponentName = typeof ComponentNames[number]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export { VDropdown, VMenu, VTooltip } from './dist/components'; | ||
export { Placement } from './dist/utils'; | ||
export { TriggerEvent } from './dist/components/PopperWrapper.vue.js'; | ||
export { hideAllPoppers, recomputeAllPoppers } from './dist/components/Popper.js'; | ||
|
||
export { default as Popper } from './dist/components/Popper.vue.js'; | ||
export { default as PopperContent } from './dist/components/PopperContent.vue.js'; | ||
export { default as PopperMethods } from './dist/components/PopperMethods.js'; | ||
export { default as PopperWrapper } from './dist/components/PopperWrapper.vue.js'; | ||
export { default as ThemeClass } from './dist/components/ThemeClass.js'; | ||
export { default as Tooltip } from './dist/components/Tooltip.js'; | ||
export { default as TooltipDirective } from './dist/components/TooltipDirective.vue.js'; | ||
|
||
export declare const ComponentNames: readonly ['VDropdown' | 'VMenu' | 'VTooltip' | 'Popper' | 'PopperContent' | 'PopperMethods' | 'PopperWrapper' | 'ThemeClass' | 'Tooltip' | 'TooltipDirective']; | ||
export type ComponentName = typeof ComponentNames[number]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export { VDropdown, VMenu, VTooltip } from './dist/components' | ||
export { hideAllPoppers, recomputeAllPoppers } from './dist/components/Popper' | ||
|
||
export { default as Popper } from './dist/components/Popper.vue' | ||
export { default as PopperMethods } from './dist/components/PopperMethods' | ||
export { default as PopperWrapper } from './dist/components/PopperWrapper.vue' | ||
export { default as ThemeClass } from './dist/components/ThemeClass' | ||
export { default as Tooltip } from './dist/components/Tooltip' | ||
export { default as TooltipDirective } from './dist/components/TooltipDirective.vue' | ||
|
||
export const ComponentNames = ['VDropdown', 'VMenu', 'VTooltip', 'Popper', 'PopperContent', 'PopperMethods', 'PopperWrapper', 'ThemeClass', 'Tooltip', 'TooltipDirective'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export { VDropdown, VMenu, VTooltip } from './dist/components.mjs' | ||
export { hideAllPoppers, recomputeAllPoppers } from './dist/components/Popper.mjs' | ||
|
||
export { default as Popper } from './dist/components/Popper.vue' | ||
export { default as PopperMethods } from './dist/components/PopperMethods.mjs' | ||
export { default as PopperWrapper } from './dist/components/PopperWrapper.vue' | ||
export { default as ThemeClass } from './dist/components/ThemeClass.mjs' | ||
export { default as Tooltip } from './dist/components/Tooltip.mjs' | ||
export { default as TooltipDirective } from './dist/components/TooltipDirective.vue' | ||
|
||
export const ComponentNames = ['VDropdown', 'VMenu', 'VTooltip', 'Popper', 'PopperContent', 'PopperMethods', 'PopperWrapper', 'ThemeClass', 'Tooltip', 'TooltipDirective'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './dist/directives'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// only for build, excluded from the package | ||
declare module '@nuxt/schema' { | ||
import type { InlinePreset, UnimportOptions } from 'unimport' | ||
export type HookResult = Promise<void> | void | ||
export interface ImportPresetWithDeprecation extends InlinePreset { | ||
} | ||
export interface ImportsOptions extends UnimportOptions {} | ||
export interface Component { | ||
pascalName: string; | ||
kebabName: string; | ||
export: string; | ||
filePath: string; | ||
shortPath: string; | ||
chunkName: string; | ||
prefetch: boolean; | ||
preload: boolean; | ||
global?: boolean; | ||
island?: boolean; | ||
mode?: 'client' | 'server' | 'all'; | ||
/** | ||
* This number allows configuring the behavior of overriding Nuxt components. | ||
* If multiple components are provided with the same name, then higher priority | ||
* components will be used instead of lower priority components. | ||
*/ | ||
priority?: number; | ||
} | ||
export interface NuxtHooks { | ||
'imports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult | ||
'components:extend': (components: Component[]) => HookResult | ||
} | ||
export interface Nuxt { | ||
options: { | ||
build: { | ||
transpile: string[] | ||
} | ||
css: string[] | ||
imports: ImportsOptions | ||
} | ||
hook: <H extends keyof NuxtHooks>(hook: H, callback: NuxtHooks[H]) => void | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { defineNuxtModule } from '@nuxt/kit' | ||
import type { FloatingVueDirectivesOptions } from 'floating-vue/directives' | ||
import type { FloatingVueComponentsOptions } from 'floating-vue/components' | ||
|
||
export interface FloatingVueNuxtOptions { | ||
directives?: FloatingVueDirectivesOptions | ||
components?: FloatingVueComponentsOptions | ||
} | ||
|
||
const _default: ReturnType<typeof defineNuxtModule> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review this, I guess we should add a |
||
|
||
export default _default |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { defineNuxtModule } from '@nuxt/kit' | ||
import type { FloatingVueDirectivesOptions } from 'floating-vue/directives' | ||
import type { FloatingVueComponentsOptions } from 'floating-vue/components' | ||
|
||
export interface FloatingVueNuxtOptions { | ||
directives?: FloatingVueDirectivesOptions | ||
components?: FloatingVueComponentsOptions | ||
} | ||
|
||
const _default: ReturnType<typeof defineNuxtModule> | ||
|
||
export default _default |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,48 @@ | ||
export default async function (_, _nuxt) { | ||
import { | ||
FloatingVueDirectives, | ||
enableDirectives, | ||
prepareFloatingVueComponents, | ||
} from 'floating-vue/unimport-presets' | ||
|
||
/** | ||
* Nuxt module implementation. | ||
* @param options {import('./nuxt').FloatingVueNuxtOptions} | ||
* @param _nuxt {import('@nuxt/schema').Nuxt} | ||
* @returns {Promise<void>} | ||
*/ | ||
export default async function (options = {}, _nuxt) { | ||
const { addPluginTemplate } = await import('@nuxt/kit') | ||
|
||
/** @type {import('@nuxt/schema').Nuxt} */ | ||
const nuxt = (this && this.nuxt) || _nuxt | ||
|
||
const imports = nuxt.options.imports | ||
imports.addons = enableDirectives(imports.addons) | ||
|
||
nuxt.hook('imports:sources', (sources) => { | ||
sources.push( | ||
FloatingVueDirectives(options.directives), | ||
) | ||
}) | ||
|
||
nuxt.hook('components:extend', async (registry) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove async There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we don't need the plugin using Nuxt auto-import stuff: just register the plugin if imports is disabled. We should add a new option to the module to use auto-import or global registration. |
||
const c = prepareFloatingVueComponents(options.components) | ||
for (const component of c) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move prepare to the for loop |
||
registry.push({ | ||
pascalName: component.pascalName, | ||
kebabName: component.kebabName, | ||
export: component.export, | ||
filePath: component.filePath, | ||
shortPath: component.filePath, | ||
chunkName: component.kebabName, | ||
prefetch: false, | ||
preload: false, | ||
global: false, | ||
mode: 'all', | ||
}) | ||
} | ||
}) | ||
|
||
nuxt.options.css.push('floating-vue/dist/style.css') | ||
|
||
addPluginTemplate({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to add
tsc-alias
as dev dependency,unbuild
ortsdown
will resolve these entries, vite requires resolve.aliasThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsdown
doesn't support stubbing yet...