![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
angular-remove-di-loaders
Advanced tools
This module is for you if:
But you're in the unfortunate situation where:
$q
and $http
Basically, if you have code that looks something like this:
define('my-module', [
'angular';
'some-dependency/foo',
'./some-local-dependency/bar'
], function() {
return angular.module('my-module', [
'foo',
'bar',
'baz'
]).factory('someHelper', function someHelperFactory($q, $foo) {
return function someHelper() {
// do something
}
}).factory('someUtil', function someUtilFactory($http, $bar) {
return function someUtil() {
// do something else
}
});;
});
And you'd prefer it to look like this:
import { $q, $http } from 'angular';
import { $foo } from 'some-dependency/foo';
import { $bar } from './some-local-dependency/bar';
export function someHelper() {
// do something
}
export function someUtil() {
// do something else
}
Disclaimer: is this a hack? Yes, we're bending angular in some weird directions. But, it makes for much more sane and easier to reason about application code -- and we're running it in production with no problems at all. That said, use at your own risk.
// Make sure we're exposing __dirname and __filename in our modules
node: {
__dirname: true,
__filename: true
},
// Point webpack to the righr place to find our loaders
resolveLoader: {
modulesDirectories: [
require('path').dirname(require.resolve('angular-webpack-remove-di-loaders/loaders'))
]
},
// Include angular-es6-interop for all client code using angular dependencies, and es6 imports and exports
preLoaders: [
{
test: /\.js/,
loader: 'angular-es6-interop',
exclude: /node_modules|jquery|angular(\.min)?\.js|\.build/
}
],
// Include angular-remove-di for angular.js
loaders: [
{
test: /angular(\.min)?\.js/,
loader: 'exports?angular!imports?uiShims!angular-remove-di'
},
]
This works best if you have a bootstrap.js
like the following:
require('angular')
require('angular-ui-router')
angular.bootstrap(document.body, ['app']);
require('./app.js');
All of angular's providers can be imported directly from angular:
import { $q, $http, $timeout } from 'angular';
Any of your ES6 exports will be usable as angular factories:
export var $foo = 'bar';
import './foo';
angular.module().factory('$foo', function($foo) {
...
});
And any any of your angular factories will be usable as ES6 imports:
angular.module().factory('$bar', function() {
...
});
import { $bar } from './bar';
This way, you can incrementally remove angular modules, and transition to pure unbridled ES6 joy without having to re-write your whole app from scratch.
Enjoy!
FAQs
Remove DI for angular, support ES6 modules
The npm package angular-remove-di-loaders receives a total of 0 weekly downloads. As such, angular-remove-di-loaders popularity was classified as not popular.
We found that angular-remove-di-loaders demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.