Comments (9)
Oops! I'll take care of this today. I'm at an airport right now, but I
should have a moment to do this shortly. :)
-Jason
On Dec 28, 2013 8:44 AM, "Bodo Kaiser" [email protected] wrote:
Hello @benbria https://github.com/benbria
I would like to use aliasify but did not found it in the npm repository.
Could you publish it?PS: I would prefer just passing a plain js hash to the transform as I it
makes independent from how you handle your configuration:var builder = browserify();
builder.transform(require('./aliasify')(app.settings.aliasify));
//...
Best,
Bo—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2
.
from aliasify.
There was a lively discussion here btw, about the configuration of transform options. :)
from aliasify.
I do not find the discussion?
Ps: good flight!
Am 28.12.2013 um 16:23 schrieb Jason Walton [email protected]:
There was a lively discussion here btw, about the configuration of transform options. :)
—
Reply to this email directly or view it on GitHub.
from aliasify.
A link would be good. :) browserify/browserify#546
Package is now published. Working on configuring. I'm going to make it so you do:
aliasify = require('aliasify').configure(config, {configDir: __dirname});
where configDir
is used to resolve relative paths in the config
.
from aliasify.
Ah okay was on the wrong repository...
I am not aware of your implementation in detail but from my experience its the most easiest to pass it directly to the function as you suggested first in the discussion.
Example with HTML + custom parser option:
var through = require('through');
var regex = /\.[0-9a-z]+$/i;
module.exports = function(options) {
return function(filename) {
var template = '';
if (!isHTMLFile(filename)) {
return through();
}
var stream = through(read, end);
function read(string) {
template += string;
}
function end() {
var module = 'module.exports =';
if (options && options.callback) {
template = options.callback(template);
}
module += JSON.stringify(template);
this.queue(module);
this.queue(null);
}
return stream;
};
};
function isHTMLFile(filename) {
var extension = regex.exec(filename).pop();
return extension === '.html';
}
from aliasify.
I also would move the directory option into the config hash.
from aliasify.
I played around a bit and found also an interesting approach. Unfortunately browserify loads the file before the transform so it will always crash...
var through = require('through');
module.exports = function(options) {
return function(filename) {
console.log(filename);
console.log(replace(filename, options));
return through();
};
};
function replace(string, options) {
for (var key in options) {
var path = options[key];
if (hasPrefix(string, key)) {
string = string.replace(key, path);
}
}
return string;
}
function hasPrefix(string, prefix) {
return string.substring(0, prefix.length) === prefix;
}
from aliasify.
Ok, you can now set configuration either by doing:
aliasify = require('aliasify').configure({
aliases: {
"d3": "./shims/d3.js"
},
configDir: __dirname,
verbose: false
});
configure()
returns a new instance of aliasify, so you can generate another instance of aliasify with a different configuration if you need to, without affecting the first one.
Lemme know if that works for you. Thanks!
from aliasify.
Yes works everything! Thank you much for your patience :)
from aliasify.
Related Issues (20)
- Resolve index.js when no file is provided HOT 3
- Support .jsx files HOT 3
- working with folders ?
- Replace alias in dependencies? HOT 6
- Aliasify code in modules HOT 4
- Support passing falafel option (for ecmaVersion 6) HOT 1
- Does aliasify work with CoffeeScript files? HOT 4
- Alias and dot notation HOT 2
- Is there support for bower installations with aliasify? HOT 1
- regex in aliases HOT 2
- how to ignore the non-css file HOT 6
- support for alias value of false like the browser field, maps to empty module HOT 2
- Directory separator should be / always HOT 1
- Does not work if code contains ES6 syntax HOT 12
- No value is exported from my es6 module after applying aliasify transform HOT 7
- Not working with Vue? HOT 6
- Always resolve relative urls relative to package.json
- Replace sub-module's relative require HOT 6
- i can haz path? HOT 2
- aliasify doesn't work with split-require
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aliasify.