davidjerleke / embla-carousel

A lightweight carousel library with fluid motion and great swipe precision.
https://www.embla-carousel.com
MIT License
5.94k stars 180 forks source link

Added `embla-carousel` as a dependency for CodeSandbox template #685

Closed zaaakher closed 8 months ago

zaaakher commented 8 months ago

Fixes #684

I had to add embla-carousel as a dependency of embla-carousel-docs so that it can be used in createSandboxReactPackageJson.ts dynamically

zaaakher commented 8 months ago

I might be missing something,

What do you use to automate updating the embla-carousel** versions in all the package.json's of all the packages in this monorepo?

davidjerleke commented 8 months ago

I might be missing something,

What do you use to automate updating the embla-carousel** versions in all the package.json's of all the packages in this monorepo?

@zaaakher good question! These commands in the root package.json will do that:

https://github.com/davidjerleke/embla-carousel/blob/01036845655e843e21eac50f28c0e61dab06ed4c/package.json#L51-L53

Best, David

zaaakher commented 8 months ago

@davidjerleke so it seems that the unrecognized embla-carousel in CodeSandbox is not resolved yet.

The only way I was able to fix it is by making embla-carousel a dependency in createSandboxReactPackageJson.ts like this:

    dependencies: {
      react: dependencies.react,
      'react-dom': dependencies['react-dom'],
      'react-scripts': '4.0.0',
      'embla-carousel-react': dependencies['embla-carousel-react'],
      'embla-carousel': dependencies['embla-carousel'], <--- here (assuming embla-carousel moved back to dependencies)
      ...(plugins && plugins)
    },

Does that mean I should move embla-carousel back as a regular dependency in embla-carousel-docs like before?

davidjerleke commented 8 months ago

@davidjerleke so it seems that the unrecognized embla-carousel in CodeSandbox is not resolved yet.

The only way I was able to fix it is by making embla-carousel a dependency in createSandboxReactPackageJson.ts like this:

    dependencies: {
      react: dependencies.react,
      'react-dom': dependencies['react-dom'],
      'react-scripts': '4.0.0',
      'embla-carousel-react': dependencies['embla-carousel-react'],
      'embla-carousel': dependencies['embla-carousel'], <--- here (assuming embla-carousel moved back to dependencies)
      ...(plugins && plugins)
    },

Does that mean I should move embla-carousel back as a regular dependency in embla-carousel-docs like before?

If I spin up a new npm or yarn project locally and import the types from embla-carousel when using embla-carousel-react, it just works. And with pnpm installing it as a devDependency works. Maybe CodeSandbox handles dependencies differently than all package managers?

So yes: If adding it as a dependency works, we have to settle with this special solution for the CodeSandboxes only. Sorry for the back and forth. Didn't know CodeSandbox works that way. Thank you 👍!

zaaakher commented 8 months ago

Don't worry about it 👌

I just pushed a commit and everything works properly now 👍