wessberg / rollup-plugin-ts

A TypeScript Rollup plugin that bundles declarations, respects Browserslists, and enables seamless integration with transpilers such as babel and swc
MIT License
496 stars 32 forks source link

How to use this with svelte, css, various import types? #224

Open RobbieTheWagner opened 6 months ago

RobbieTheWagner commented 6 months ago

Question

Hi! I am trying to use this plugin to simplify out setup for generating types for Shepherd.js. However, I have been unable to get it to run because we have some Svelte files and those files generate some CSS files and we have CSS imports in the library etc.

I am unsure if it is just the order of the plugins I am using or if we need extra steps to make things work. Do you have any tips on how to get things working?

Are we supposed to exclude CSS, Svelte etc files with exclude: ['**/*.css', '**/*.svelte']? Or are my plugins out of order and there is a way to not exclude them?

RobbieTheWagner commented 6 months ago

If I exclude those file types, I get a different error:

│ [!] RollupError: src/utils/floating-ui.ts (4:2): "autoUpdate" is not exported by "../node_modules/.pnpm/@floating-ui+dom@1.6.3/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.mts", imported by "src/utils/floating-ui.ts".
│ https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
│ src/utils/floating-ui.ts (4:2)
│ 2: import { shouldCenterStep } from './general.ts';
│ 3: import {
│ 4:   autoUpdate,
│      ^

I am unsure why it thinks autoUpdate is not exported because it definitely is in the node_modules. Is there something we need to do to make this plugin aware of it? I am using @rollup/plugin-node-resolve so I would assume it could find the node_modules files.

If you would like to see what I currently have, it is in this PR: https://github.com/shepherd-pro/shepherd/pull/2820

RobbieTheWagner commented 6 months ago

I would be happy to sponsor your work here @wessberg, if I can figure out how to get this working for Shepherd 😄