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

Browserify not getting the browser build specifiecd in package.json #208

Closed
danielstocks opened this issue Jan 10, 2018 · 3 comments
Closed

Comments

@danielstocks
Copy link

danielstocks commented Jan 10, 2018

After upgrading to Styletron 3.x we we're experiencing Browserify build errors related to Styletron.

Background

I'm looking at https://github.com/rtsao/styletron/blob/master/packages/styletron-react/package.json and it has the following lines:

{
  "main": "./dist/index",
  "module": "./dist/index.mjs",
  "browser": {
    "./dist/index.js": "./dist/browser.es5.js",
    "./dist/index.mjs": "./dist/browser.es5.mjs"
},

The reason our build is failing is because we're piping our browserify bundle through uglify for JS minification. But now it won't run anymore because styletron 3.x is giving us non ES5 compatible js when importing it.

Styletron 2.x works fine in our build pipeline becuase importing it give's us ES5/Browser compatible code, that will run through uglify without any errors.

Example code:

const b = browserify()
b.require('styletron-react')
b.bundle().pipe(process.stdout);

Result:

Gives me the contents of node_modules/styletron-react/dist/index.js

Expected:

If i understood Browserify correctly, should I not get node_modules/styletron-react/dist/browser.es5.js ?

@rtsao
Copy link
Member

rtsao commented Jan 10, 2018

It appears browserify and webpack differ in how they treat the browser field, which means it isn't working with browserify. Working on a fix for this.

@rtsao
Copy link
Member

rtsao commented Jan 10, 2018

This should be resolved in 3.0.3

@danielstocks
Copy link
Author

danielstocks commented Jan 11, 2018

I can confirm 3.0.3 solves the issue. Thank you @rtsao!

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

2 participants