Skip to content

Commit 6225ace

Browse files
committed
fixed error with importing JSON with ProfilingPlugin
1 parent 24b046e commit 6225ace

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎lib/debug/ProfilingPlugin.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,11 @@ const interceptTemplateInstancesFrom = (compilation, tracer) => {
266266
};
267267

268268
const interceptAllHooksFor = (instance, tracer, logLabel) => {
269-
Object.keys(instance.hooks).forEach(hookName => {
270-
instance.hooks[hookName].intercept(makeInterceptorFor(logLabel, tracer)(hookName));
271-
});
269+
if(Object.hasOwnProperty("hooks", instance)) {
270+
Object.keys(instance.hooks).forEach(hookName => {
271+
instance.hooks[hookName].intercept(makeInterceptorFor(logLabel, tracer)(hookName));
272+
});
273+
}
272274
};
273275

274276
const interceptAllParserHooks = (moduleFactory, tracer) => {

‎test/configCases/plugins/profiling-plugin/index.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import "./test.json";
2+
13
it("should generate a events.json file", () => {
24
var fs = require("fs"),
35
path = require("path"),
@@ -13,4 +15,4 @@ it("should have proper setup record inside of the json stream", () => {
1315
// convert json stream to valid
1416
var source = JSON.parse(fs.readFileSync(path.join(os.tmpdir(), "events.json"), "utf-8").toString() + "{}]");
1517
source[0].id.should.eql(1);
16-
});
18+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"json": "should work"
3+
}

0 commit comments

Comments
 (0)