Comments (8)
Thanks, I did not know, but I just saw your PR related to tsconfck.
My use-case is a TypeScript module meant for browser and node environment. I have setup a minimal example repo.
If you can take a look would be great.
The file src/index.ts
exports src/client.ts
and src/router.ts
is meant for browser.
The file src/server.ts
is meant for node.
When using yarn run build:nanobundle
, nanobundle generates the output files with declarations enabled.
It produces multiple d.ts
files for the browser bundle (not one bundled d.ts
file):
lib/client.d.ts
lib/index.d.ts
- (in addition
lib/server.d.ts
)
As a workaround I tested various settings with dts-bundle-generator
. If you run yarn run build:nanobundle:dts
, nanobundle generates the output files with declarations disabled, following dts-bundle-generator
, generates one d.ts
bundle for browser and one d.ts
bundle for node. But it takes up to 20 seconds for the command:
lib/index.d.ts
(lib/client.d.ts
is included)- (in addition
lib/server.d.ts
)
I also tested unbuild
, as a comparison you can run yarn run build:unbuild
, it will also output one bundled lib/index.d.ts
and lib/server.d.ts
.
Maybe I get this wrong and it's okay how nanobundle bundles the d.ts
. I was just wondering, since unbuild bundles the d.ts
files, as I expected.
from nanobundle.
It seems to use rollup-plugin-dts. And seems like an ideal option to do dts bundling, but I wouldn't make it the default for several reasons.
- There is no need to bundle dts (yet)
- It doesn't support all use case of typescript. Because TypeScript expects files to be split, you can run into unexpected conflicts with merged files.
- Maybe slow (20 more seconds for build... is way far)
I could experiment with the rollup for dts and introduce it with the --experimental-dts-bundling
flag, but it's not a high priority.
from nanobundle.
ref https://github.com/timocov/dts-bundle-generator#known-limitations
from nanobundle.
Any news on this?
from nanobundle.
@jrson83 nanobundle is well emitting dts files as necessary
Do you need something else?
from nanobundle.
@cometkim sorry I can't find anything about dts bundling in the docs. Is it possible to bundle .d.ts
files with nanobundle
like dts-bundle-generator
does?
from nanobundle.
I had considered it, but dts-bundling isn't compatible with multiple entries and TypeScript's NodeNext resolution.
Welcome if you have any approach to do it.
from nanobundle.
I could experiment with the rollup for dts and introduce it with the --experimental-dts-bundling flag, but it's not a high priority.
That would be great! Thank you.
from nanobundle.
Related Issues (20)
- `--standalone` flag doesn't work
- Bundling Types for a `.cts` File Doesn't Work in a Project With `type` set to `module` HOT 1
- CSS modules
- Support build without bundling HOT 2
- Enable declarationMap by default
- duplicate of tsconfck on the public npm registry HOT 1
- Plan to next build tool
- dev command HOT 5
- Subpath imports condition
- Support CSS bundling
- ESBuild codegen
- jsx transform doesn't work HOT 19
- Clean command
- Migrate to Clipanion HOT 3
- Dependency Dashboard
- Support for outputting bundles with JSX extensions HOT 1
- `--no-sourcemap` flag not working HOT 1
- How to generate only index.d.ts without bundle files? HOT 3
- Support custom condition
- Support subpath imports
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nanobundle.