diff --git a/test/comparison-tests/create-and-execute-test.js b/test/comparison-tests/create-and-execute-test.js index 5589bd622..09839de3d 100644 --- a/test/comparison-tests/create-and-execute-test.js +++ b/test/comparison-tests/create-and-execute-test.js @@ -169,38 +169,21 @@ function createWebpackConfig(paths, optionsOriginal, useWatchApi) { } function createWebpackWatchHandler(done, paths, testState, options, test) { - let timoutId; - let statsString; - let errString; return function (err, stats) { - if (timoutId) { - clearTimeout(timoutId); - timoutId = undefined; - } const patch = setPathsAndGetPatch(paths, testState, options); - const currentErrString = errToString(err, paths); - if (currentErrString) { - errString = errString ? errString + "\n\n" + currentErrString : currentErrString; - } - const currentStatsString = statsToString(stats, testState, paths); - if (currentStatsString) { - statsString = statsString ? statsString + "\n\n" + currentStatsString : currentStatsString; - } - timoutId = setTimeout(function () { - cleanHashFromOutput(stats, paths.webpackOutput); - copySync(paths.webpackOutput, paths.actualOutput); - rimraf.sync(paths.webpackOutput); + cleanHashFromOutput(stats, paths.webpackOutput); + + copySync(paths.webpackOutput, paths.actualOutput); + rimraf.sync(paths.webpackOutput); + + handleErrors(err, paths); - handleErrors(errString, paths); - errString = undefined; + storeStats(stats, testState, paths); - storeStats(statsString, paths); - statsString = undefined; + compareFiles(paths, test, patch); - compareFiles(paths, test, patch); - copyPatchOrEndTest(paths.testStagingPath, testState.watcher, testState, done); - }, 2000); + copyPatchOrEndTest(paths.testStagingPath, testState.watcher, testState, done); } } @@ -219,35 +202,26 @@ function setPathsAndGetPatch(paths, testState, options) { return patch; } -function handleErrors(errString, paths) { - if (errString) { +function handleErrors(err, paths) { + if (err) { const errFileName = 'err.txt'; - fs.writeFileSync(path.join(paths.actualOutput, errFileName), errString); - } -} -function errToString(err, paths) { - if (err) { const errString = err.toString() .replace(new RegExp(regexEscape(paths.testStagingPath + path.sep), 'g'), '') .replace(new RegExp(regexEscape(rootPath + path.sep), 'g'), '') .replace(new RegExp(regexEscape(rootPath), 'g'), '') .replace(/\.transpile/g, ''); - return errString; - } -} -function storeStats(statsString, paths) { - if (statsString) { - const statsFileName = 'output.txt'; - fs.writeFileSync(path.join(paths.actualOutput, statsFileName), statsString); + fs.writeFileSync(path.join(paths.actualOutput, errFileName), errString); } } -function statsToString(stats, testState, paths) { +function storeStats(stats, testState, paths) { if (stats && stats.hash !== testState.lastHash) { testState.lastHash = stats.hash; + const statsFileName = 'output.txt'; + // do a little magic to normalize `\` to `/` for asset output const newAssets = {}; Object.keys(stats.compilation.assets).forEach(function (asset) { @@ -262,7 +236,8 @@ function statsToString(stats, testState, paths) { .replace(new RegExp(regexEscape(rootPath), 'g'), '') .replace(new RegExp(regexEscape(rootPathWithIncorrectWindowsSeparator), 'g'), '') .replace(/\.transpile/g, ''); - return statsString; + + fs.writeFileSync(path.join(paths.actualOutput, statsFileName), statsString); } } diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/bundle.js b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/bundle.js index 3070ad2a3..60f7f137c 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/bundle.js +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/bundle.js @@ -106,7 +106,7 @@ eval("\nexports.__esModule = true;\nvar lib_1 = __webpack_require__(/*! ./lib */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4 // Add new number\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?"); +eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?"); /***/ }) diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/output.txt index 006ebe934..ce5d245f0 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch0/output.txt @@ -6,10 +6,4 @@ ../lib/out/tsconfig.tsbuildinfo 70 KiB [emitted] Entrypoint main = bundle.js [./app.ts] 131 bytes {main} [built] -[./lib/out/index.js] 130 bytes {main} - - Asset Size Chunks Chunk Names -bundle.js 4.37 KiB main [emitted] main -Entrypoint main = bundle.js -[./app.ts] 131 bytes {main} -[./lib/out/index.js] 161 bytes {main} [built] \ No newline at end of file +[./lib/out/index.js] 130 bytes {main} \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch1/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch1/output.txt index 8cbabebc0..4f26ba788 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch1/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch1/output.txt @@ -2,4 +2,4 @@ bundle.js 4.4 KiB main [emitted] main Entrypoint main = bundle.js [./app.ts] 169 bytes {main} [built] -[./lib/out/index.js] 161 bytes {main} \ No newline at end of file +[./lib/out/index.js] 161 bytes {main} [built] \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/bundle.js b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/bundle.js index 2a571212e..e6463502c 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/bundle.js +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/bundle.js @@ -106,7 +106,7 @@ eval("\nexports.__esModule = true;\nvar lib_1 = __webpack_require__(/*! ./lib */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4,\n five: 5\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?"); +eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4 // Add new number\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?"); /***/ }) diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/output.txt index 2097642cb..45e4a892c 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch3/output.txt @@ -6,10 +6,4 @@ ../lib/out/tsconfig.tsbuildinfo 70 KiB [emitted] Entrypoint main = bundle.js [./app.ts] 169 bytes {main} [built] -[./lib/out/index.js] 161 bytes {main} - - Asset Size Chunks Chunk Names -bundle.js 4.4 KiB main [emitted] main -Entrypoint main = bundle.js -[./app.ts] 169 bytes {main} -[./lib/out/index.js] 156 bytes {main} [built] \ No newline at end of file +[./lib/out/index.js] 161 bytes {main} \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch4/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch4/output.txt index c5a7e0e80..337d531c9 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch4/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-3.8/patch4/output.txt @@ -2,7 +2,7 @@ bundle.js 4.42 KiB main [emitted] main Entrypoint main = bundle.js [./app.ts] 186 bytes {main} [built] [1 error] -[./lib/out/index.js] 156 bytes {main} +[./lib/out/index.js] 156 bytes {main} [built] ERROR in app.ts ./app.ts diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch0/bundle.js b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch0/bundle.js deleted file mode 100644 index db2c96801..000000000 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch0/bundle.js +++ /dev/null @@ -1,113 +0,0 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./app.ts"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./app.ts": -/*!****************!*\ - !*** ./app.ts ***! - \****************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar lib_1 = __webpack_require__(/*! ./lib */ \"./lib/out/index.js\");\nconsole.log(lib_1.lib.one, lib_1.lib.two, lib_1.lib.three);\n\n\n//# sourceURL=webpack:///./app.ts?"); - -/***/ }), - -/***/ "./lib/out/index.js": -/*!**************************!*\ - !*** ./lib/out/index.js ***! - \**************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4 // Add new number\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?"); - -/***/ }) - -/******/ }); \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch0/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch0/output.txt deleted file mode 100644 index e981876f3..000000000 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch0/output.txt +++ /dev/null @@ -1,5 +0,0 @@ - Asset Size Chunks Chunk Names -bundle.js 4.4 KiB main [emitted] main -Entrypoint main = bundle.js -[./app.ts] 167 bytes {main} -[./lib/out/index.js] 161 bytes {main} [built] \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch1/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch1/output.txt index bda35c374..0cc24db4b 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch1/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch1/output.txt @@ -2,4 +2,4 @@ bundle.js 4.44 KiB main [emitted] main Entrypoint main = bundle.js [./app.ts] 205 bytes {main} [built] -[./lib/out/index.js] 161 bytes {main} \ No newline at end of file +[./lib/out/index.js] 161 bytes {main} [built] \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch3/bundle.js b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch3/bundle.js deleted file mode 100644 index d4ea42a43..000000000 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch3/bundle.js +++ /dev/null @@ -1,113 +0,0 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./app.ts"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./app.ts": -/*!****************!*\ - !*** ./app.ts ***! - \****************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar lib_1 = __webpack_require__(/*! ./lib */ \"./lib/out/index.js\");\nconsole.log(lib_1.lib.one, lib_1.lib.two, lib_1.lib.three, lib_1.lib.four); // consume new number\n\n\n//# sourceURL=webpack:///./app.ts?"); - -/***/ }), - -/***/ "./lib/out/index.js": -/*!**************************!*\ - !*** ./lib/out/index.js ***! - \**************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\nexports.__esModule = true;\nexports.lib = {\n one: 1,\n two: 2,\n three: 3,\n four: 4,\n five: 5\n};\n//# sourceMappingURL=index.js.map\n\n//# sourceURL=webpack:///./lib/out/index.js?"); - -/***/ }) - -/******/ }); \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch3/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch3/output.txt index 901a8dc53..19b95a267 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch3/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch3/output.txt @@ -6,10 +6,4 @@ ../lib/out/tsconfig.tsbuildinfo 70 KiB [emitted] Entrypoint main = bundle.js [./app.ts] 205 bytes {main} [built] -[./lib/out/index.js] 161 bytes {main} - - Asset Size Chunks Chunk Names -bundle.js 4.44 KiB main [emitted] main -Entrypoint main = bundle.js -[./app.ts] 205 bytes {main} -[./lib/out/index.js] 156 bytes {main} [built] \ No newline at end of file +[./lib/out/index.js] 161 bytes {main} \ No newline at end of file diff --git a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch4/output.txt b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch4/output.txt index f1084ccfc..85d645c15 100644 --- a/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch4/output.txt +++ b/test/comparison-tests/projectReferencesOutDirWithPackageJsonAlreadyBuilt/expectedOutput-transpile-3.8/patch4/output.txt @@ -2,4 +2,4 @@ bundle.js 4.45 KiB main [emitted] main Entrypoint main = bundle.js [./app.ts] 222 bytes {main} [built] -[./lib/out/index.js] 156 bytes {main} \ No newline at end of file +[./lib/out/index.js] 156 bytes {main} [built] \ No newline at end of file