Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

ng-hot-reload-loader

Package Overview
Dependencies
7
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.1.0

77

index.js

@@ -1,16 +0,48 @@

const template = require('lodash.template'),
fs = require('fs'),
path = require('path'),
loaderUtils = require('loader-utils'),
templatePath = path.join(__dirname, 'src', 'source.js.tpl'),
compiled = template(fs.readFileSync(templatePath, 'utf8')),
corePath = require.resolve('ng-hot-reload-core'),
sourceMap = require('source-map');
const loaderUtils = require('loader-utils');
const corePath = require.resolve('ng-hot-reload-core');
const sourceMap = require('source-map');
// Tests that we don't modify our own library files, i.e. files that are in
// ng-hot-reload/packages or one of the suffixed ng-hot-reload-* directories.
var noTransform = /ng-hot-reload([\\/]packages[\\/]|-)(core|loader|standalone)/;
const noTransform =
/ng-hot-reload([\\/]packages[\\/]|-)(core|loader|standalone)/;
const codeWrapperTop = ({ corePath, forceRefresh, preserveState }) =>
`
/* ng-hot-reload-loader */
(function(__ngHotReloadLoaderAngularGlobal) {
var angular = module.hot ? (function() {
var loader = require(${ corePath });
return loader.decorateAngular({
angular: __ngHotReloadLoaderAngularGlobal,
forceRefresh: Boolean(${ forceRefresh }),
preserveState: Boolean(${ preserveState })
});
})() : __ngHotReloadLoaderAngularGlobal;
try {
(function() {/* ng-hot-reload-loader end*/
`;
const codeWrapperBottom = ({ requireAngular }) =>
`
})();/* ng-hot-reload-loader */
} finally {
(function() {
if (module.hot && angular.__ngHotReload$didRegisterProviders) {
module.hot.accept(function(err) {
if (err) {
console.error(err);
}
});
}
})();
}
})(${ requireAngular });
/* ng-hot-reload-loader end */
`;
async function transform(source, map) {
const callback = this.async();
if (this.cacheable) {

@@ -22,12 +54,6 @@ this.cacheable();

if (noTransform.test(this.resourcePath)) {
return callback(null, source, map);
return this.callback(null, source, map);
}
const sourcePlaceholder = '<SOUCE_PLACEHOLDER>';
const result = compiled({
const topPart = codeWrapperTop({
corePath: JSON.stringify(corePath),
source: sourcePlaceholder,
requireAngular: typeof options.requireAngular === 'string' ?
options.requireAngular :
'(require("angular"), angular)',
// Boolean options that default to true.

@@ -37,3 +63,16 @@ forceRefresh: options.forceRefresh !== false,

});
const [topPart, bottomPart] = result.split(sourcePlaceholder);
const bottomPart = codeWrapperBottom({
requireAngular: typeof options.requireAngular === 'string' ?
options.requireAngular :
'require("angular")',
});
if (!map) {
// No source maps, just concat the source code together.
const result = topPart + source + bottomPart;
this.callback(null, result, map);
return;
}
const callback = this.async();
await sourceMap.SourceMapConsumer.with(map, null, async (consumer) => {

@@ -40,0 +79,0 @@ const node = sourceMap.SourceNode.fromStringWithSourceMap(source, consumer);

{
"main": "index.js",
"name": "ng-hot-reload-loader",
"version": "3.0.0",
"version": "3.1.0",
"description": "Webpack hot loader for angularjs apps",

@@ -13,3 +13,2 @@ "scripts": {

"loader-utils": "^1.4.0",
"lodash.template": "^4.5.0",
"ng-hot-reload-core": "^3.0.0",

@@ -21,3 +20,3 @@ "source-map": "^0.7.3"

},
"gitHead": "5c4744a6cf6e64331a89bbf7718c9e1c264dbbc0"
"gitHead": "e031461d188ffbc838b2348e0dfd8da76f29227e"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc