Skip to content

Commit db193d5

Browse files
committed
fix a race-condition with tokensByFile
Because we’re setting `tokensByFile` before and after an async action, and many of these actions can happen at the same time, there’s a race condition where the incorrect `tokensByFile` can be set. This accomplishes the same desire for caching by just keeping the loader for every file since the loader already caches `tokensByFile`, and prevents the race condition.
1 parent 46b2c83 commit db193d5

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,9 @@ module.exports = function (browserify, options) {
118118
// collect visited filenames
119119
filenames.push(filename);
120120

121+
var loader = new FileSystemLoader(rootDir, plugins);
121122
return through(function noop () {}, function end () {
122123
var self = this;
123-
var loader = new FileSystemLoader(rootDir, plugins);
124-
125-
// pre-populate the loader's tokensByFile
126-
loader.tokensByFile = tokensByFile;
127124

128125
loader.fetch(path.relative(rootDir, filename), '/').then(function (tokens) {
129126
var output = 'module.exports = ' + JSON.stringify(tokens);

0 commit comments

Comments
 (0)