razzle icon indicating copy to clipboard operation
razzle copied to clipboard

Add build type `library`

Open piecyk opened this issue 4 years ago • 7 comments

🚀 Feature request

Current Behavior

There is not possible? to build library with razzle. As with rise of monorepo popularity there should be an option to easy extract a common util, or react component and build it using razzle!

Desired Behavior

Should be possible build library!

Suggested Solution

Add support for new build type to razzel, as most building blocks are there ( added with client-only support 🎉 )

Who does this impact? Who is this for?

All users.

Describe alternatives you've considered

None.

Additional context

None.

piecyk avatar Apr 26 '20 20:04 piecyk

what do you mean by library something like https://github.com/jaredpalmer/after.js?

nimaa77 avatar Apr 26 '20 20:04 nimaa77

No, something like https://github.com/transitive-bullshit/create-react-library but not using rollup to build the output, but razzle.

For example i have a react component Button in my-app-1 package ( build with razzle ), then added my-app-2 ( build with razzle client only ) and want to share that Button between those two.

I think that would be awesome to have one tool to manage building all the pieces in monorepo.

piecyk avatar Apr 26 '20 20:04 piecyk

Should be doable. A good way to understand how this should work is: https://webpack.js.org/guides/author-libraries/ . If someone tries to implement this I am all for it 😀

fivethreeo avatar Oct 06 '20 23:10 fivethreeo

If you want to try hacking on this, I have a workflow:

npm install -g yalc
git clone https://github.com/jaredpalmer/razzle.git
cd razzle
git checkout -B canary
NODE_ENV=development yarn install ---ignore-engines
yarn try-example basic
# or any example in the examples dir
# or just add your own in the examples dir
cd example
yarn start
yarn build

Make changes to razzle and run:

yarn updateyalc
yarn build
yarn start

In the example dir to use your modified razzle

You can even add dependencies in the example dir with yarn

fivethreeo avatar Jan 14 '21 05:01 fivethreeo

Been thinking about this and this would be awesome in monorepos. Maybe even develop component libraries with a example that reload when you edit the library live.

fivethreeo avatar Feb 26 '21 22:02 fivethreeo

Maybe make buildType have library-esm library-amd library-cjs, and allow mixing like library-esm-amd-cjs

fivethreeo avatar Feb 27 '21 00:02 fivethreeo

Not sure if this is a good idea. I see other projects doing libraries better, like tsdx. Could do it here for es6 but not for ts since typings is gretting too different from Babel and needs a different toolchain and deps than Babel and webpack.

fivethreeo avatar May 16 '21 23:05 fivethreeo