Skip to content

Commit 9c06770

Browse files
committed
assert: lazy load acorn
This makes sure acorn is only loaded in case it is necessary. PR-URL: #19863 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 252eb2d commit 9c06770

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/assert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const {
3333
}
3434
} = require('internal/errors');
3535
const { openSync, closeSync, readSync } = require('fs');
36-
const { parseExpressionAt } = require('internal/deps/acorn/dist/acorn');
3736
const { inspect } = require('util');
3837
const { EOL } = require('os');
3938
const { NativeModule } = require('internal/bootstrap/loaders');
@@ -173,6 +172,8 @@ function getErrMessage(call) {
173172
fd = openSync(filename, 'r', 0o666);
174173
const buffers = getBuffer(fd, line);
175174
const code = Buffer.concat(buffers).toString('utf8');
175+
// Lazy load acorn.
176+
const { parseExpressionAt } = require('internal/deps/acorn/dist/acorn');
176177
const nodes = parseExpressionAt(code, column);
177178
// Node type should be "CallExpression" and some times
178179
// "SequenceExpression".

0 commit comments

Comments
 (0)