question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🗣[Discussion] Distribute individual bundles for each component

See original GitHub issue

It would be awesome if I could import only a single component at a time by going a bit deeper into the filesystem, for example something like:

import Flex from '@primer/components/dist/Flex';
// or maybe even
import Flex from '@primer/components/Flex';

That mainly requires creating a JS file per component that has a module.exports instead of a single index.esm.js file. That would allow my app to only pull in the code that I am really using, instead of all components, and also solve #455 and #454.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
shawnbotcommented, May 21, 2019

@mxstbr this is possible, but it’s not a great public API because in order for people to use it they need to know how to configure [insert your build tool(s) here] to compile our source files node_modules/@primer/components. If there’s a generally acceptable way to do that, we’re all ears! But it seems like having CommonJS and/or ESM builds of each component would be best, no?

0reactions
BinaryMusecommented, Apr 17, 2020

I’m picking up this issue again. Some recent discussion:

  • I’ve successfully been able to create a transpilation-only build of each component into individual modules (not packages), but there are still a few issues to take care of here involving certain resolvers and duplicated code in the built modules
  • We’d like to bundle some components into an “experimental” directory where experiments and other incomplete components could live and be usable without being exported in the main @primer/components export
  • We should update (or auto-generate) the TypeScript declare module directories in the index.d.ts file so that both src and dist work (or maybe we should drop src and only use dist?)
  • It would be nice if we could write some components in TS
Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Techniques for Bundle Splitting and Lazy Loading in React
Bundling Javascript code into several files is known as bundle splitting. ... Dynamic imports enable every component to play the role of a ......
Read more >
Best Practices For Distributing And Promoting Your NFTs To ...
Furthermore, and besides the aesthetic part, owning your NFT contract means that you can import it in third-party marketplaces that allow for ...
Read more >
Code Splitting with Laurie Barth - DEV Community 👩‍💻👨‍💻
Excerpt: "According to MDN, 'Code splitting is the splitting of code into various bundles or components which can then be loaded on-demand or...
Read more >
تويتر \ Alex / KATT 🐱 (alexdotjs@) - Twitter
With tRPC + Next.js 13, you'll have your components render on the edge but be able to have the "server logic" in a...
Read more >
AIcrowd | Data Purchasing Challenge 2022
Distribution shifts have to be anticipated. In this competition, you face these data purchasing challenges in the context of an multi-label ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found