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

Use bem-xjst with browserify #249

Closed
zefirka opened this issue Apr 22, 2016 · 4 comments
Closed

Use bem-xjst with browserify #249

zefirka opened this issue Apr 22, 2016 · 4 comments

Comments

@zefirka
Copy link

zefirka commented Apr 22, 2016

I have some requires of CommonJS modules in my bemhtml templates. Like a:

// a.bemhtml.js
block('a').match(
    // some code
    var myModule = require('moduleName');
    //some code
  )

I'm building my templates with enb-bemxjst and at the end I will get ?.bemhtml.js bundle. There are requires from bem-xjst in code:

//some code:
var inherits = require('inherits');
var Match = require('../bemxjst/match').Match;
var BemxjstEntity = require('../bemxjst/entity').Entity;

Also I have requires from my templates in this bundle. But when I try to resolve requires in my bemhtml templates with browserify - I can't do it cause of browserify can't resolve requires from bem-xjst code. Has anybody solved this problem?

Currently, in my enb technology I'm parsing bundle file, replacing all bem-xjst requirements with some strings, after I build an next bundle and replace in final bundle that strings with initial bem-xjst requires. It's pretty weird and absolutely non-maintainable solution, but currently it works.

@miripiruni
Copy link
Contributor

@zefirka the question is closed?

@zefirka
Copy link
Author

zefirka commented Apr 25, 2016

@miripiruni Pretty much. Thanks! It work.
But when I use module names like:

requires: {
    'module-name': { ... }
}

In final bundle in object which describes requirements I have:

{
    module-name: require('<path to module>')
}

@qfox
Copy link
Member

qfox commented Apr 25, 2016

@zefirka Thank you. Closing this since it's a bug in enb-bemxjst module: enb/enb-bemxjst#170

@qfox qfox closed this as completed Apr 25, 2016
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

4 participants