Skip to content
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

Browser friendly npm package #117

Open
youknowriad opened this issue Sep 4, 2018 · 6 comments
Open

Browser friendly npm package #117

youknowriad opened this issue Sep 4, 2018 · 6 comments

Comments

@youknowriad
Copy link

youknowriad commented Sep 4, 2018

In the browser context, dependencies like fs are not necessarily available. Source maps are also not important when the library is used in the browser.

Is this something you could consider: Providing a browser-friendly npm package? I'm well aware about the option here https://github.com/reworkcss/css/blob/master/lib/stringify/index.js#L31 but unfortunately, this can't be statically analyzed by bundlers to avoid bundling the source map file entirely.

Any thoughts?

Thanks.

Context: Trying to use this library in Gutenberg (the new WordPress editor) WordPress/gutenberg#9008

@danielhusar
Copy link

danielhusar commented Jan 21, 2019

We are using it already in browser. (but only parse api)
If you are using webpack, you can do:

node: {
  fs: 'empty',
},

in your webpack config to make it work.

@mangr3n
Copy link

mangr3n commented Apr 12, 2019

Where exactly in the webpack.config.js file does that snippet go? I assume it's not on the root of the config object.

@Ovissse
Copy link

Ovissse commented Apr 12, 2019

Where exactly in the webpack.config.js file does that snippet go? I assume it's not on the root of the config object.

Yes it's on root
https://webpack.js.org/configuration/node/#other-node-core-libraries

@mangr3n
Copy link

mangr3n commented Apr 12, 2019

Thank you

@krzysztof-grzybek
Copy link

If you want to use only parser (without stringify), it's possible to run it in browser by importing only parser:

import parser from 'css/lib/parse';

or

const parse = require('css/lib/parse');

@holblin
Copy link

holblin commented May 26, 2022

I worked on removing the source-map support. This will solve the issue. Trying to reach out to the rework members before going into the fork route (and discussing with my company for the PR route).
ref: #164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants