jgyos / system

The compact and flexible Firefox OS core
Apache License 2.0
0 stars 5 forks source link

Introduce a webpack conditional loader for bundling sources by different types #20

Closed rickychien closed 8 years ago

rickychien commented 9 years ago

Hey @jgyos/owners

According to documentation of webpack (http://webpack.github.io/docs/using-loaders.html#usage), it makes you available to preprocess sources by different customize loader. IIUC, we can have a conditional-loader to decide whether to package source or not that would depend on a given type from build time.

In order to bundle sources by a given device type, we could do some things, for instance of base_modules.js:

var moduleTV = require('conditional?type=tv!./js/modulesTV');
var modulePhone = require('conditional?type=phone!./js/modulesPhone');

When we pass the type=phone into webpack that conditional-loader is able to omit /js/modulesTV modules.

Since there is no any loader existed that can fulfill our needs to do above things, I could be going to write a conditional-loader for it.

What do you think?

gasolin commented 9 years ago

We'd first try webpack + es6 module then consider if the loader plugin is the right way to go