Skip to content

Conversation

mthaip
Copy link
Contributor

@mthaip mthaip commented Sep 20, 2025

Hi @davidjbradshaw,

I don’t have permission to manage the branch divine-master. So I created this PR to address some issues related to the Vue 3 migration and type definitions in this project:

  • I used esbuild and vue-tsc to compile the Vue components and their corresponding type declarations. The rollup-plugin-vue is no longer well supported - Vite is now the recommended approach. I had to run vue-tsc manually (see rollup.config.mjs) to build the type declarations for iframe-resizer.vue. This should fix the issue mentioned in divine-master.
  • I noticed inconsistencies in type definitions across packages and tried to refactor them to ensure all packages use the same types.

This PR is currently a proposal. Before continuing, I’d like to confirm with you if it’s okay that I:

  • Improve types across all packages by temporarily adding index.d.ts. For full TypeScript support, I would recommend refactoring index.js into index.ts (which could be a TODO for the future).

If you feel this is too much or conflicts with your current roadmap, I can reduce the scope of this PR to packages/vue only.

I'm always open to discussion!

@@ -0,0 +1,3 @@
import IframeResizer from './iframe-resizer.vue'

export default IframeResizer
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 would suggest using a default export for the component, so developers can freely choose the name under which they install iframe-resizer.

Copy link
Contributor Author

@mthaip mthaip Sep 20, 2025

Choose a reason for hiding this comment

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

I just used the type in packages/react/index.d.ts as a reference

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the Vue component implementation by migrating from Vue 2 to Vue 3 using the Composition API and improves TypeScript support across packages. The changes involve restructuring the build system to use esbuild and vue-tsc for better type generation.

  • Migrates Vue component from Options API to Composition API with TypeScript
  • Replaces rollup-plugin-typescript with esbuild for better performance
  • Introduces centralized type definitions in packages/core/types.ts

Reviewed Changes

Copilot reviewed 10 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tsconfig.base.json Establishes base TypeScript configuration for the project
rollup.config.mjs Updates build pipeline to use esbuild and adds type generation
packages/vue/tsconfig.json Vue-specific TypeScript configuration extending base config
packages/vue/index.ts New TypeScript entry point replacing JavaScript version
packages/vue/index.js Removes old JavaScript entry point
packages/vue/iframe-resizer.vue Migrates to Vue 3 Composition API with TypeScript
packages/core/types.ts Centralizes type definitions for reuse across packages
packages/angular/directive.ts Updates to use shared types from core package
package.json Adds Vue 3 and new build dependencies
build/pkgJson.js Updates package configuration for type declarations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


// Resizer Events
export type ResizerEvents = {
onCLosed?: (iframeId: string) => void // Remove in v6
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

There's a typo in the event name 'onCLosed' - it should be 'onClosed' with a lowercase 'L'.

Suggested change
onCLosed?: (iframeId: string) => void // Remove in v6
onClosed?: (iframeId: string) => void // Remove in v6

Copilot uses AI. Check for mistakes.

Comment on lines +342 to +345
execSync(
'vue-tsc -p packages/vue/tsconfig.json --declaration --emitDeclarationOnly --declarationMap false',
{ stdio: 'inherit' },
)
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

Using execSync for type generation is a blocking operation that could slow down the build process. Consider using the async exec() or integrating vue-tsc programmatically for better performance.

Copilot uses AI. Check for mistakes.

Comment on lines +115 to +118
}) => {
this.onScroll.next(event)
return true
},
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

The hardcoded 'return true' value should be documented or made configurable. This change affects the scroll behavior but lacks explanation for why it always returns true.

Copilot uses AI. Check for mistakes.

@davidjbradshaw
Copy link
Owner

Hi,

Thanks for this. My long term plan is to refactor the index.js files in core and child packages into smaller more testable components and then migrate to TS. As part of this I'd like to move from Rollup to Vite. When I moved to Rollup 18 months ago, I looked a Vite, but at that time their was no way to get it to create multiple packages.

This will then be released as version 6.

I agree the types are a bit of a mess, they where contributed by different people and I'm not much of a TS coder.

In the meantime my main concern is to avoid any breaking changes. So I'm wondering if in tidying up the types it has created any changes that would break builds for people currently uses this with TS?

D.

@mthaip
Copy link
Contributor Author

mthaip commented Sep 22, 2025

Hi @davidjbradshaw ,

I would say that if the JS modules are migrated to TypeScript correctly and the types match those already defined in the *.d.ts file (e.g., in @iframe-resizer/react), the build of people using this package should not fail. I’m not 100% sure, but we can definitely verify everything before the release.

Regarding this PR: I tried migrating the React package and noticed that it’s a huge effort to cover everything within this PR. I would suggest reducing the scope to the Vue package only. Once you migrate to TypeScript, I would be happy to support you.

Thai

@davidjbradshaw
Copy link
Owner

Hey,

So sorry for the slow reply, I've been ill in bed all week and I'm still not feeling that great. I've tried to look through this, but my brain is still melting when I look at code.

I agree it would be great just to focus on Vue for this PR. That is the biggest miss when it comes to TS support at the moment.

Thanks,
Dave.

@mthaip
Copy link
Contributor Author

mthaip commented Oct 1, 2025

Hi,
I hope you’re feeling better now, and thanks for your reply! I’ll focus on Vue only and let you know once the PR is ready.

@davidjbradshaw
Copy link
Owner

davidjbradshaw commented Oct 1, 2025

Thank you. I'm slowly getting a bit better.

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.

2 participants