Skip to content

Commit

Permalink
Build: fix race condition in demo (#8827)
Browse files Browse the repository at this point in the history
(fixes eslint/archive-website#363)

Since 3ec436e was committed, the demo at http://eslint.org/demo has occasionally failed to load properly -- see eslint/archive-website#363 for more details. It appears that the issue was caused by a change to the build process in that commit which involved placing two browserified modules in the same bundle file. Based on #8465 (comment) this was changed in order to pass the tests in karma, but the tests seem to pass without the change.

I'm not exactly sure what the root cause of the issue is. It only occurs when an unrelated file is loaded by requirejs after the eslint bundle, and that unrelated load files. My best guess at the moment is that requirejs was only able to infer the module name of the eslint bundle correctly when it contained a single anonymous module. When it contained two anonymous modules, requirejs couldn't infer their names, so it threw an error if there were no more modules to load after that. Depending on the state of the browser cache and the network, there would only sometimes be another module left to load after loading the eslint bundle, so this led to seemingly random errors in the demo.
  • Loading branch information
not-an-aardvark authored and ilyavolodin committed Jun 29, 2017
1 parent c693be5 commit c4f2e29
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Makefile.js
Expand Up @@ -758,13 +758,12 @@ target.browserify = function() {

// 5. browserify the temp directory
nodeCLI.exec("browserify", "-x espree", `${TEMP_DIR}linter.js`, "-o", `${BUILD_DIR}eslint.js`, "-s eslint", "--global-transform [ babelify --presets [ es2015 ] ]");
nodeCLI.exec("browserify", "-x espree", `${TEMP_DIR}rules.js`, "-o", `${TEMP_DIR}rules.js`, "-s rules", "--global-transform [ babelify --presets [ es2015 ] ]");

// 6. Browserify espree
nodeCLI.exec("browserify", "-r espree", "-o", `${TEMP_DIR}espree.js`);

// 7. Concatenate Babel polyfill, Espree, and ESLint files together
cat("./node_modules/babel-polyfill/dist/polyfill.js", `${TEMP_DIR}espree.js`, `${BUILD_DIR}eslint.js`, `${TEMP_DIR}rules.js`).to(`${BUILD_DIR}eslint.js`);
cat("./node_modules/babel-polyfill/dist/polyfill.js", `${TEMP_DIR}espree.js`, `${BUILD_DIR}eslint.js`).to(`${BUILD_DIR}eslint.js`);

// 8. remove temp directory
rm("-r", TEMP_DIR);
Expand Down

0 comments on commit c4f2e29

Please sign in to comment.