gatsby-module-loader
Advanced tools
Comparing version 1.1.0-alpha.22c8a6f1 to 2.0.0-alpha.1
39
index.js
"use strict"; | ||
var _stringify = require("babel-runtime/core-js/json/stringify"); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* | ||
@@ -9,4 +15,3 @@ Based on Tobias Koppers @sokra bundle-loader | ||
*/ | ||
const loaderUtils = require(`loader-utils`); | ||
const path = require(`path`); | ||
var loaderUtils = require("loader-utils"); | ||
@@ -17,4 +22,4 @@ module.exports = function () {}; | ||
const query = loaderUtils.parseQuery(this.query); | ||
let chunkName = ``; | ||
var query = loaderUtils.getOptions(this) || {}; | ||
var chunkName = ""; | ||
@@ -26,28 +31,8 @@ if (query.name) { | ||
}); | ||
chunkName = `, ${JSON.stringify(chunkName)}`; | ||
} | ||
const request = loaderUtils.stringifyRequest(this, `!!` + remainingRequest); | ||
var request = loaderUtils.stringifyRequest(this, "!!" + remainingRequest); | ||
var chunkComment = chunkName && "/* webpackChunkName: " + (0, _stringify2.default)(chunkName) + " */ "; | ||
const callback = `function() { return require(` + request + `) }`; | ||
const executor = ` | ||
return require.ensure([], function(_, error) { | ||
if (error) { | ||
console.log('bundle loading error', error) | ||
cb(true) | ||
} else { | ||
cb(null, ${callback}) | ||
} | ||
}${chunkName}); | ||
`; | ||
const result = ` | ||
require( | ||
${loaderUtils.stringifyRequest(this, `!${path.join(__dirname, `patch.js`)}`)} | ||
); | ||
module.exports = function(cb) { ${executor} } | ||
`; | ||
return result; | ||
return "module.exports = () => import(" + chunkComment + request + ")"; | ||
}; |
{ | ||
"name": "gatsby-module-loader", | ||
"version": "1.1.0-alpha.22c8a6f1", | ||
"version": "2.0.0-alpha.1", | ||
"description": "_Based on https://github.com/webpack/bundle-loader and https://github.com/NekR/async-module-loader_", | ||
@@ -8,3 +8,5 @@ "main": "index.js", | ||
"build": "babel src --out-dir . --ignore __tests__", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"watch": "babel -w src --out-dir . --ignore __tests__", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepublish": "cross-env NODE_ENV=production npm run build" | ||
}, | ||
@@ -14,7 +16,11 @@ "author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
"dependencies": { | ||
"loader-utils": "^0.2.16" | ||
"babel-runtime": "^6.26.0", | ||
"common-tags": "^1.4.0", | ||
"dedent": "^0.7.0", | ||
"loader-utils": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1" | ||
"babel-cli": "^6.26.0", | ||
"cross-env": "^5.0.5" | ||
} | ||
} |
10
patch.js
@@ -6,3 +6,3 @@ "use strict"; | ||
function patch() { | ||
var head = document.querySelector(`head`); | ||
var head = document.querySelector("head"); | ||
var ensure = __webpack_require__.e; | ||
@@ -16,3 +16,3 @@ var chunks = __webpack_require__.s; | ||
var handler = function (error) { | ||
var handler = function handler(error) { | ||
if (!callback) return; | ||
@@ -71,5 +71,5 @@ | ||
if (script.tagName !== `SCRIPT`) { | ||
if (typeof console !== `undefined` && console.warn) { | ||
console.warn(`Script is not a script`, script); | ||
if (script.tagName !== "SCRIPT") { | ||
if (typeof console !== "undefined" && console.warn) { | ||
console.warn("Script is not a script", script); | ||
} | ||
@@ -76,0 +76,0 @@ |
@@ -5,11 +5,11 @@ "use strict"; | ||
module.exports.prototype.apply = function (compiler) { | ||
compiler.plugin(`compilation`, function (compilation) { | ||
compilation.mainTemplate.plugin(`require-extensions`, function (source, chunk, hash) { | ||
compiler.plugin("compilation", function (compilation) { | ||
compilation.mainTemplate.plugin("require-extensions", function (source, chunk, hash) { | ||
if (chunk.chunks.length > 0) { | ||
var buf = []; | ||
buf.push(``); | ||
buf.push(``); | ||
buf.push(`// expose the chunks object`); | ||
buf.push(this.requireFn + `.s = installedChunks;`); | ||
buf.push(""); | ||
buf.push(""); | ||
buf.push("// expose the chunks object"); | ||
buf.push(this.requireFn + ".s = installedChunks;"); | ||
@@ -16,0 +16,0 @@ return source + this.asString(buf); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
45918
8
1
4
2
104
1
+ Addedbabel-runtime@^6.26.0
+ Addedcommon-tags@^1.4.0
+ Addeddedent@^0.7.0
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbig.js@5.2.2(transitive)
+ Addedcommon-tags@1.8.2(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddedent@0.7.0(transitive)
+ Addedemojis-list@3.0.0(transitive)
+ Addedjson5@1.0.2(transitive)
+ Addedloader-utils@1.4.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
- Removedbig.js@3.2.0(transitive)
- Removedemojis-list@2.1.0(transitive)
- Removedjson5@0.5.1(transitive)
- Removedloader-utils@0.2.17(transitive)
- Removedobject-assign@4.1.1(transitive)
Updatedloader-utils@^1.0.2