Giter VIP home page Giter VIP logo

Comments (8)

jrson83 avatar jrson83 commented on June 20, 2024 1

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.

cometkim avatar cometkim commented on June 20, 2024 1

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.

cometkim avatar cometkim commented on June 20, 2024

ref https://github.com/timocov/dts-bundle-generator#known-limitations

from nanobundle.

jrson83 avatar jrson83 commented on June 20, 2024

Any news on this?

from nanobundle.

cometkim avatar cometkim commented on June 20, 2024

@jrson83 nanobundle is well emitting dts files as necessary

Do you need something else?

from nanobundle.

jrson83 avatar jrson83 commented on June 20, 2024

@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.

cometkim avatar cometkim commented on June 20, 2024

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.

jrson83 avatar jrson83 commented on June 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.