-
Notifications
You must be signed in to change notification settings - Fork 507
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
Multiple entries to output multiple build files #175
Comments
This shouldn’t be too tough. Thanks for the write up and use case |
another use case is adding command line tool (package.json
running |
Yep. This should be easy to implement just have to fool around with the cjs entry generation so it does it multiple times |
To follow up with @elado 's comment, if your code uses web-workers at all it would be nice to be able to use multiple entry points split across output files so that worker scripts are separate from everything else. |
Related to this I guess, How could I avoid having one single outputted file for ESM build?
I am looking for having something like Material UI folks put together, so it is more ESM friendly by default. |
So this seems to be a bug caused by the tsdx/src/createRollupConfig.ts Lines 32 to 33 in d621994
I created a workaround-ish with module.exports = {
rollup(config, options) {
const outputDir = process.cwd() + '/dist/'
const extension = '.' + config.output.file.split('.').slice(1).join('.')
let filename = config.input.split('src/')[1] // remove src/
filename = filename.split('.')[0] // remove extension, if any
config.output.file = outputDir + filename + extension
console.log(config.output.file)
// replace / with __ for UMD names
config.output.name = filename.replace('/', '__')
return config
}
} and this will work with Buuut besides being very hacky, the output has some issues (possibly minor, pending your use case):
Also #365 seems directly related to this. Also related to this issue, @yordis created a separate issue #321 for that specific use case above, which I also gave a partial workaround for in #321 (comment) |
So I realized there's one other fairly big issue with my workaround: If you're not using CJS though, you don't have a need for CJS entry files, so the hacky workaround could potentially work for you. EDIT: fixed the duplicate type declarations issue in the PR as well, it similarly can only be fixed internally. Another issue is that |
Does anyone know how to do this just with raw rollup? I’m having trouble deduplicating my own files/making d.ts files show up in the right places. |
@brainkim guess this would be helpful |
Hello! I just ran into this as well. Would love some way to export a library that also bundles a CLI, and I'm happy to pitch in to make that happen. |
I spent ten minutes with adding globs and comma-separated paths before giving up going into the issues and searching/finding jaredpalmer#175 / jaredpalmer#367. Maybe delete the `(s)` until the issue is resolved to prevent other people from doing the same. :)
Is it possible to use |
- refactor: Move build command to build.sh note: this will allow multiple module build entry files - feat: Add indexify.js script, this will generate moduleName.js files note: this is because tsdx.config.js override do not generate js files - feat: Add tsdx.config.js to generate multiple esm, cjs modules - refactor: Move index file out from module folders refer jaredpalmer/tsdx#175 (comment) Important note: Base on the comment tsdx do not support multiple entry
* chore: Build multiple modules instead of one index.js - refactor: Move build command to build.sh note: this will allow multiple module build entry files - feat: Add indexify.js script, this will generate moduleName.js files note: this is because tsdx.config.js override do not generate js files - feat: Add tsdx.config.js to generate multiple esm, cjs modules - refactor: Move index file out from module folders refer jaredpalmer/tsdx#175 (comment) Important note: Base on the comment tsdx do not support multiple entry * chore: Update size-limit checker for all modules * doc: Update CHANGELOG.md and README.md Co-authored-by: Wilson Lim <wilson@goquo.com>
Hey guys, I'm happy with using tsup now 👍🏼 |
Hey, what's the status of this? It looks like it's holding up a lot of projects, judging by the refs. |
@mikestopcontinues It's currently part of the v0.15.0 milestone. Not sure if it's actively worked on at the moment. I have personally moved away from TSDX for now. |
Thanks @fnky . I guess I'll stick with microbundle for now, but I'll keep an eye out here. :) |
I've switched to https://github.com/preconstruct/preconstruct |
can't believe it's a year without fixing. @jaredpalmer do you need some help with that? |
Can somebody from TSDX team mentions if this is totally a bad idea or it's on the roadmap so I can make the best decision about my problem? |
@ImanMh At this point, I think you need to look elsewhere. Look into esbuild. It handles typescript, .d.ts files, and multiple entries. |
Current Behavior
When building source with multiple entries, using
--entry src/**.ts
the build only uses the source of the first file it finds as the main entry point for ESM and CJS output.Desired Behavior
It would be nice to be able to specify multiple destinations for different source files from a single codebase.
Suggested Solution
A solution could be to change the behavior of
--entry
flag, so that instead of outputting only definition files from multiple sources, it should output entry points for each specified entry file.For example, with a folder structure like this:
Running
tsdx build --entry src/**.ts
or--entry src/code.ts src/ui.ts
will yield the following output files:Where
code.js
andui.js
are similar toindex.js
for single entry projects.Who does this impact? Who is this for?
This is useful for building applications, plugins or other types of projects, where multiple entries are required, without having to create a monolithic repo architecture with a custom build process to combine build files.
An example is the recently released Figma Plugin API, which specifies a main file for the underlying plugin code, and a ui file for browser UI part.
See an example project using React and Webpack to create a Figma UI plugin
Describe alternatives you've considered
Additional context
I was looking for ways to specify multiple entries with
--entry
as outlined in #28 but it seems to only output source files for the first file it finds and the rest just outputs as definition files, not actual source files. This is a bit confusing and may be a bug as it shares the same property name as webpack (entry
), but works differently.The text was updated successfully, but these errors were encountered: