joris-calvat / locale-url-solver

0 stars 0 forks source link

Universal or server-side only ? #5

Open mbriziarelli opened 7 years ago

mbriziarelli commented 7 years ago

In the documentation, you write :

it can be used : server side with your prefered framework in the browser if you require('locale-url-solver') it in your javascript blender

As an experienced developper, you don't ignore that in many situations, the "blender" is configured to not use its loaders for source code contained in the node_module folder. This is an example from one of the webpack.config.js files I wrote :

const bundleTopCommon = {
    entry: {
        "top": "./index.js",
    },
    externals: {
        "ric": "window.RIC || (window.RIC = {})",
        "pagevars": "window.pagevars || (window.pagevars = {})",
        "datalayer": "window.dataLayer || (window.dataLayer = [])",
        "global": "window"
    },
    watch: "true",
    module: {
        loaders: [
            {
                test: /(\.jsx|\.js)$/,
                exclude: /node_modules/,
                loader: 'babel-loader?cacheDirectory=true'
            },
            {
                test: /\.json$/,
                exclude: /node_modules/,
                loader: 'json-loader'
            }
        ]
    }
};

module.exports = bundleTopCommon;

As you can see, I wrote an exclude property in each loader config, allowing me to speed up the build process.

In this situation, if your code in index.js is located in the node_module folder, it will not be transpiled to ES5. And will crash in older browsers like IE11.

I think you should therefore provide a build system and a dist folder, with the result of the transpilation from ES2015 to ES5.