EranGrin / vue-web-component-wrapper

vue3 - web component wrapper plugin
https://erangrin.github.io/vue-web-component-wrapper/
60 stars 8 forks source link

Warning about the __NO_SIDE_EFFECTS__ after building with vite #41

Closed fabiiomiiguel closed 1 week ago

fabiiomiiguel commented 2 weeks ago

When I build my project with vite It throws this warning regarding the __NO_SIDEEFFECTS. I found in a rollup issue the solution.

Screenshot 2024-11-07 at 01 12 12

Also when I build this project it also throws an warning related using named and default exports together. I also found in a rollup issue the solution to disable this warning.

Screenshot 2024-11-07 at 01 58 17

I did a pull request with a suggestion of a fix for both warnings.

EranGrin commented 2 weeks ago

Hi @fabiiomiiguel, thank you for the Issue/PR, indeed I haven't tried to use rollup, Would you mind sharing your working rollup setup vite config? I would be glad to add it to the docs.

fabiiomiiguel commented 2 weeks ago

Yes of course, this is the build configs that I use with vite.

...
    build: {
      emptyOutDir: true,
      target: 'ES2020',
      rollupOptions: {
        output: {
          entryFileNames: '[name].js',
        },
      },
      cssCodeSplit: false,
    },
...

EDIT: @EranGrin I create a simple project from the official Vue 3 template in StackBlitz, so you can see the error also

https://stackblitz.com/edit/vitejs-vite-16kd3r

EranGrin commented 1 week ago

The PR is Merged, and the docs are updated thanks, closing the issue now

fabiiomiiguel commented 1 week ago

@EranGrin sorry to bother you again.

I saw your new version and sadly the problem persists. I think it's related with the first /* #__NO_SIDE_EFFECTS__ */ manually added to the build.

I found out the solution in the no-side-effects-notation-spec.md, which is to remove the white spaces.

So if you don't mind could you please do the following steps so I don't need to do a new pull request.

  1. Replace /*! @__NO_SIDE_EFFECTS__ */ by /*#__NO_SIDE_EFFECTS__*/ in the package/src/api-custom-element.ts file.

  2. Instead of adding /* #__NO_SIDE_EFFECTS__ */ to the build add /*#__NO_SIDE_EFFECTS__*/ in the file.

EranGrin commented 1 week ago

Second try 😄

fabiiomiiguel commented 1 week ago

@EranGrin when doing the build make sure we don't have spaces in /*! #__NO_SIDE_EFFECTS__ */. Because your last commit as it in the package/dist/vue-web-component-wrapper.es.js and also ‎package/dist/vue-web-component-wrapper.umd.js.

EranGrin commented 1 week ago

I need to check why the build creates add this space, I am quite busy this week so it will take a few days, thanks