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

Libraries compiled with 3.0.8 may be incompatible with 3.0.7 #3493

Closed
relief-melone opened this issue Mar 27, 2021 · 12 comments
Closed

Libraries compiled with 3.0.8 may be incompatible with 3.0.7 #3493

relief-melone opened this issue Mar 27, 2021 · 12 comments
Labels
🔥 p5-urgent Priority 5: this fixes build-breaking bugs that affect most users and should be released ASAP.

Comments

@relief-melone
Copy link

Version

3.0.8

Reproduction link

https://gitlab.com/rm-issues/v3.0.8-using-plugin-fails

Steps to reproduce

Clone the repository.

Run npm serve

Open localhost:8080

Check dev console

What is expected?

The Home view from the basic setup should be displayed correctly when using an external library.

What is actually happening?

If you use version 3.08. vue cannot be loaded in the external library. Instead when trying to import anything from vue in App.vue you will be getting the error

Uncaught TypeError: Object(...) is not a function


I am the creator of vue-mapbox-ts and up until this morning everything worked out well. But this morning it stopped to work. After some digging I found that for my test page I was still using an cdn import and vue had been updated to version 3.0.8. 3.0.7 was (and is) running just fine.

I tried to boil down the problem to the minimal changes based on a default vue application created by @vue/cli and this is what I did

  • vue create (with default settings)
  • install my library using npm
  • add the use to main.ts

I did not use any components from that library and left the App.vue as it was so there are no more changes to the basic installation. However the error

Uncaught TypeError: Object(...) is not a function

will be thrown in App.vue when trying to import defineComponent (or anything else for that matter) from "vue"

Now usually this happens if I mess up something with my externals when I am testing component libraries and multiple instances of vue are present but this is not the case here. The plugin just registers some components. Everything is still working fine with 3.0.7.

Now I am still getting into some of the details of creating component libraries in vue3 and my implementation might not be perfect. However I think that with just new patch release 3.0.7 -> 3.0.8 vue should behave in the same manner.

Just for testing I also tried importing vue from a cdn and defining the externals in my webpack config to rule out this reason but the outcome is the same

@HcySunYang
Copy link
Member

You should rebuild your project(vue-mapbox-ts) with vue 3.0.8's compiler. In 3.0.8, we refactored the runtime implementation of scope style, it has no changes to the user-side API, but for library authors, you must rebuild your library with vue 3.0.8's new compiler, otherwise it cannot be used for 3.0.8+

@LinusBorg
Copy link
Member

LinusBorg commented Mar 27, 2021

@HcySunYang Then this is a breaking change introduced in a patch release.

That's not really what we want to do unless absolutely necessary in terms of bug fixing, I would say.

We should discuss this in the team, re-evaluate the real impact of this on lib maintainers and come up with a strategy to handle this situation.

@HcySunYang
Copy link
Member

That's not really what we want to do unless absolutely necessary in terms of bug fixing

This is a necessary refactoring for slot scope id, see #3374, yes, this is a breaking change for library authors.

I just realized that the build resources of vue-mapbox-ts contain outdated code:

image

So I think it must be that the version of the vue compiler used by the library author is lower than 3.0.8

@LinusBorg
Copy link
Member

Still, if it's breaking a ton of libs, we should consider rolling this back, communicating the change with the community and give them time to prepare.

Because at the end, it's not only affecting lib authors, it would break many apps that use a lib that was compiled with a compiler version <3.0.8, with no clear reason that the app's developers could infer.

@HcySunYang
Copy link
Member

I agree, but this is actually a problem that must occur during dev or build process. Users should be easy to detect and it does not seem to bring hidden risks to users.

@relief-melone
Copy link
Author

relief-melone commented Mar 27, 2021

Thanks for the quick reply. That was indeed the problem. Since in my test project (where I am actually importing the source from my library) I was adding vue from cdn but using the compiler version 3.0.7 this did not work. And importing the built version did not work as it was compiled using an older version.

Now I am just caught up a little. I have to use rollup to bundle this lib even tough I would happily use vite because I have to use it in projects that are dependent on vue2 and cannot be updatet to vue3 just jet because of dependency issues. And while vite is not as far as I know able to build Vue2 Apps the current rollup vue plugin (I guess this is the one compiling vue for rollup?) does not implement the new compiler yet. (beta 10 depends on 3.0.0-rc.5)

This should not be your concern and does not affect this issue but it may affect others that try to maintain component libraries using the power of vue3 but still beeing able to make those libraries work in vue2.

Anyway thanks for the quick reply again. Always amazed how active this community is even on a saturday ;)

@HcySunYang
Copy link
Member

As an afterword, it seems that this PR(#3334) will encounter the same situation, since #3334 has been marked as a plan for 3.1, maybe we can introduce these changes together in 3.1 ?

@LinusBorg
Copy link
Member

LinusBorg commented Mar 27, 2021

I agree, but this is actually a problem that must occur during dev or build process. Users should be easy to detect and it does not seem to bring hidden risks to users.

Yes, people upgrading to 3.0.8 will likely find this bug during build, and can then roll back to 3.0.7.

Still, this is problematic. 3.0.8 brings a ton of other important bug fixes that people now can't use until all their dependencies have upgraded to a version compiled with the 3.0.8 compiler.

Disclaimer We still need to figure out how broad the effect of the issue is.

@relief-melone this is not really an issue for vite itself. you can upgrade the compiler in a vite project as well, it's not hardcoded to 3.0.7 or anything.

I'll also reopen this issue as for us, it's not resolved.

@LinusBorg LinusBorg reopened this Mar 27, 2021
@LinusBorg
Copy link
Member

maybe we can introduce these changes together in 3.1 ?

Would be a better strategy. Also gives us to to rethink how to introduce the change while creating as little friction as possible.

@LinusBorg LinusBorg changed the title Cannot use external library Libraries compiled with 3.0.8 may be incompatible with 3.0.7 Mar 27, 2021
@LinusBorg LinusBorg added the 🔥 p5-urgent Priority 5: this fixes build-breaking bugs that affect most users and should be released ASAP. label Mar 27, 2021
@LinusBorg
Copy link
Member

rollup-plugin-vue supports all compiler versions:

https://github.com/vuejs/rollup-plugin-vue/blob/next/package.json#L26

you just have to make sure that the compiler installed in the project is for 3.0.8.

But before doing that maybe wait a bit until we can communicate clearly how we proceed with this issue.

This would still only be an issue for users that also publish their vue3 libraries for vue2

Vue 2 isn't affected by this at all as the compiler change only affects Vue 3 projects.

@relief-melone
Copy link
Author

OK updating the compiler manually to 3.0.8 also seems to work for the rollup plugin (probably just forgot to npm serve again the first time). The only thing that I noticed is that backward compatiblity would also be an issue. So if I compile my library with 3.0.8 but leave my test environment on 3.0.7 this will also result in the same error

@relief-melone
Copy link
Author

I can confirm that with 3.0.9 everything is working again as expected. Thanks alot

@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔥 p5-urgent Priority 5: this fixes build-breaking bugs that affect most users and should be released ASAP.
Projects
None yet
Development

No branches or pull requests

3 participants