frontend-boilerplate icon indicating copy to clipboard operation
frontend-boilerplate copied to clipboard

Add webpack modulesDirectories option and replace ES7 autobinding with ES7 property declaration

Open dbertella opened this issue 9 years ago • 4 comments

I think the modulesDirectories option in webpack is a realy handy way to handle modules, and I'm not sure about autobinding, but I don't think it's the best way to use methods since it will bind a new function in every render cycle. I may be wrong, feel free to deny it if I am

dbertella avatar May 05 '16 08:05 dbertella

Webpack's moduleDirectories is a very nice way to walk directories a la node_modules. I used it for shared folders.

However you will have to create a Webpack bundle before running tests on Node, and that slows the tests down.

Babel has a module resolver feature and with babel-plugin-resolver you obtain the same features that NODE_PATH provides Node.

I've switched to babel-plugin-resolver because I can run tests using babel-register alone which is faster than creating a Webpack bundle. It also doesn't tie me into Webpack for a build system..

You of course will still have to create a bundle if you require Webpack loaders e.g. import style from './style.css'.

eddyystop avatar May 05 '16 10:05 eddyystop

Sure, you are right about it I'll have to use karma to run test actually, I will look into it than. Can be useful.

2016-05-05 12:41 GMT+02:00 Eddyystop [email protected]:

Webpack's moduleDirectories is a very nice way to walk directories a la node_modules. I used it for shared folders.

However you will have to create a Webpack bundle before running tests on Node, and that slows the tests down.

Babel has a module resolver feature and with babel-plugin-resolver you obtain the same features that NODE_PATH provides Node.

I've switched to babel-plugin-resolver because I can run tests using babel-register which is faster than creating a Webpack bundle.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/tj/frontend-boilerplate/pull/76#issuecomment-217122090

Daniele Bertella *Front end developer *

+39.340.490.57.80 LinkedIn: danielebertella http://it.linkedin.com/in/danielebertella/ Twitter: _denb https://twitter.com/_denb www.danielebertella.com

dbertella avatar May 05 '16 13:05 dbertella

I've been preferring to set aliases, so that I can set an alias to "lib", "shared", etc... and just require('lib/...') It's a bit of a break from the "node way" but, it's worked for me...

A somewhat convoluted webpack config

tracker1 avatar May 07 '16 03:05 tracker1

I've been using browserify instead now, not sure when I'll have time to update this though

tj avatar May 07 '16 03:05 tj