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

Non minified distribution is broken #1355

Closed
maciej-ka opened this issue Dec 15, 2017 · 5 comments
Closed

Non minified distribution is broken #1355

maciej-ka opened this issue Dec 15, 2017 · 5 comments

Comments

@maciej-ka
Copy link
Contributor

Version

styled-components: 2.2.4
babel-plugin-styled-components: 1.3.0

Reproduction

https://www.webpackbin.com/bins/-KeeZCr0xKfutOfOujxN
https://codesandbox.io/s/rkmNRByE4

Steps to reproduce

  1. cd /tmp
  2. mkdir project1
  3. cd project1/
  4. /tmp/project1
  5. yarn init -y
  6. yarn add styled-components
  7. open node_modules/styled-components/dist/styled-components.js

Expected Behavior

Distribution will not contain process.env.NODE_ENV

Actual Behavior

Several process.env.NODE_ENV statements

@mxstbr
Copy link
Member

mxstbr commented Dec 15, 2017

That is a UMD bundle that's meant to be used in a <script> tag, so it should definitely not contain any process.env.X code! (contrary to the .es.js bundle)

@maciej-ka
Copy link
Contributor Author

The problem is also present, when I build project:

  1. git clone https://github.com/styled-components/styled-components
  2. cd styled-components
  3. yarn && yarn build && yarn dev
  4. visit localhost:3000

Actual: browser has an error
screen shot 2017-12-15 at 20 30 30

@maciej-ka
Copy link
Contributor Author

maciej-ka commented Dec 15, 2017

rollup.config.js:52 should replace process.env.NODE_ENV

  prod && replace({
    'process.env.NODE_ENV': JSON.stringify(prod ? 'production' : 'development'),
  }),

Invocation of replace looks ok to me, and condition prod is true when running node_modules/.bin/rollup -c --environment PRODUCTION.

I found out that we could have newer version in package.json:124

    "rollup-plugin-replace": "^1.1.1",

however when using version 2.0.0 of this plugin problem is still present.

Update
I debugged replace call in rollup-plugin-replace and I could see replacements in action as well as a correct result returned.

@mxstbr
Copy link
Member

mxstbr commented Dec 15, 2017

Ohh it's because the styled-components.js bundle is generated with rollup -c --environment DEVELOPMENT I think??

We should have that replace always in there, unless it's the .es.js bundle!

@maciej-ka
Copy link
Contributor Author

Right, yes, how could I missed that, PR coming in a minute, thanks!

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

No branches or pull requests

2 participants