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

Dynamic require in conjunction with envify #166

Open
kwoon opened this issue Aug 22, 2016 · 2 comments
Open

Dynamic require in conjunction with envify #166

kwoon opened this issue Aug 22, 2016 · 2 comments
Labels

Comments

@kwoon
Copy link

kwoon commented Aug 22, 2016

Hi! I form the config for a large project kit in the following way in conjunction with envify

module.exports = xtend(
  require('../config/__defaults/common'),
  require('../config/__defaults/' + process.env.stage),
  require('../config/' + process.env.project + '/common'),
  require('../config/' + process.env.project + '/' + process.env.stage)
)

When i bundle project with browserify all works perfectly!

NODE_ENV=production browserify src/index.js \
  -t [envify --project ${1:-'main'} --stage ${2:-'dev'}] \
  -g uglifyify \
  > bundle.min.js

But when i try to use this browserify configuration with budo

budo src/index.js:bundle.js -P -- \
  -t [envify --project ${1:-'main'} --stage ${2:-'dev'}]

budo returns me

Cannot find module '../config/__defaults/dev'

but i have this file.

So, maybe you know what i'm doing wrong?

@mattdesl mattdesl added the bug label Aug 22, 2016
@mattdesl
Copy link
Owner

Thanks, it seems like a bug somewhere with arg/subarg parsing.

Have you tried using the API and specifying browserify: { transform: ... } } manually? It would be interesting to see if that works fine.

@kwoon
Copy link
Author

kwoon commented Aug 22, 2016

Yep, i tried hardcoded needed parameters in package.json but result the same.

  "browserify": {
      "transform": [
          "aliasify",
          ["envify", {
              "project": "main",
              "stage": "dev"
          }]
      ]
  }

Interesting that after error debugger shows me this precompiled code

module.exports = xtend(
  require('../config/__defaults/common'),
  require('../config/__defaults/' + "dev"),
  require('../config/' + "main" + '/common'),
  require('../config/' + "main" + '/' + "dev")
)

Seems like problem in 'dynamic require'...

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

No branches or pull requests

2 participants