-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the minifiers to rename the function parameters and still be able to inject #14
Comments
Right now in my project i find some workaround with help of gulp. After typescript compiling but before minification, i parse with regexp current stream content (gulp-data plugin), find any functions arguments matched to pattern like: let reservedVariables = []; .pipe(ts({
out: 'output.js',
typescript: require('typescript')
}))
.pipe(data(function(file) {
let results,
result,
res;
results = String(file.contents).match(/function[^(]*\(([^)]*)\)/g);
for (result in results) {
res = results[result].match(/function[^(]*\(([^)]*)\)/)[1].split(',');
res.forEach((value) => {
if (value === '') {
return false;
}
if (/I[A-Z]\w*/.test(value)) {
reservedVariables.push(value);
}
});
}
reservedVariables = reservedVariables.filter(function (value, index, self) {
return self.indexOf(value) === index;
});
return reservedVariables;
}))
.pipe(uglify({
mangle: {
except: reservedVariables
}
})) |
@sanex3339 thanks for sharing that! |
You can now use:
For more details check out #33 |
To allow the minifiers to rename the function parameters and still be able to inject the right services, the function needs to be annotated.
Will be implemented using Reflection Metadata API. Useful links:
microsoft/TypeScript#2249
https://www.npmjs.com/package/reflect-metadata
https://github.com/matjaz/property-DI/
The text was updated successfully, but these errors were encountered: