Created
July 3, 2012 09:52
-
-
Save jed/3038799 to your computer and use it in GitHub Desktop.
browserify-alias-test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
lib.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
hello: "Hello" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
hello: "こんにちは" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "alias-test", | |
"version": "0.0.0", | |
"dependencies": { | |
"browserify": "~1.13.5" | |
}, | |
"scripts": { | |
"test": "node ./test.js" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var locale = require("locale") | |
console.log(locale.hello) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs") | |
, browserify = require("browserify") | |
, app = browserify() | |
app.alias("/node_modules/locale/index.js", "/locales/en") | |
app.addEntry("./src.js") | |
fs.writeFileSync("./lib.js", app.bundle()) | |
require("./lib") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a test case for using browserify's
.alias
method to build localized javascript bundles.the idea is that you should be able to run the browserification process for each locale, and create localized bundles that ship only the assets required from the app.
unfortunately, i can't get it to work, as documented in browserify/browserify#184. would love to hear any ideas on how to get past this. as an alternative i could just symlink
/locales/index.js
to each locale file before building, but such an ugly hack shouldn't be needed.to test this out, just run this one-liner: