From 52d309b09baf33689ec6fdbac35c96a0501d4af9 Mon Sep 17 00:00:00 2001 From: smphhh Date: Tue, 15 Nov 2016 13:09:09 +0200 Subject: [PATCH 1/5] Add test for handling re-exported const enums --- .../constEnumReExportWatch/app.ts | 3 + .../constEnumReExportWatch/bar.ts | 3 + .../expectedOutput-2.1/bundle.js | 52 +++++++++++++ .../expectedOutput-2.1/bundle.transpiled.js | 74 +++++++++++++++++++ .../expectedOutput-2.1/output.transpiled.txt | 6 ++ .../expectedOutput-2.1/output.txt | 4 + .../expectedOutput-2.1/patch0/bundle.js | 52 +++++++++++++ .../patch0/bundle.transpiled.js | 74 +++++++++++++++++++ .../patch0/output.transpiled.txt | 6 ++ .../expectedOutput-2.1/patch0/output.txt | 4 + .../constEnumReExportWatch/foo.ts | 1 + .../constEnumReExportWatch/patch0/bar.ts | 3 + .../constEnumReExportWatch/tsconfig.json | 7 ++ .../constEnumReExportWatch/webpack.config.js | 17 +++++ 14 files changed, 306 insertions(+) create mode 100644 test/comparison-tests/constEnumReExportWatch/app.ts create mode 100644 test/comparison-tests/constEnumReExportWatch/bar.ts create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.transpiled.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.transpiled.txt create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.txt create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.transpiled.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.transpiled.txt create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.txt create mode 100644 test/comparison-tests/constEnumReExportWatch/foo.ts create mode 100644 test/comparison-tests/constEnumReExportWatch/patch0/bar.ts create mode 100644 test/comparison-tests/constEnumReExportWatch/tsconfig.json create mode 100644 test/comparison-tests/constEnumReExportWatch/webpack.config.js diff --git a/test/comparison-tests/constEnumReExportWatch/app.ts b/test/comparison-tests/constEnumReExportWatch/app.ts new file mode 100644 index 000000000..198fe45fd --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/app.ts @@ -0,0 +1,3 @@ +import { BarEnum } from './foo'; + +console.log(BarEnum.Bar); diff --git a/test/comparison-tests/constEnumReExportWatch/bar.ts b/test/comparison-tests/constEnumReExportWatch/bar.ts new file mode 100644 index 000000000..96a46129a --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/bar.ts @@ -0,0 +1,3 @@ +export const enum BarEnum { + Bar = 1 +}; diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.js new file mode 100644 index 000000000..492b6e7de --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.js @@ -0,0 +1,52 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + "use strict"; + console.log(1 /* Bar */); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.transpiled.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.transpiled.js new file mode 100644 index 000000000..41ffea88a --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/bundle.transpiled.js @@ -0,0 +1,74 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var foo_1 = __webpack_require__(1); + console.log(foo_1.BarEnum.Bar); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var bar_1 = __webpack_require__(2); + exports.BarEnum = bar_1.BarEnum; + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + (function (BarEnum) { + BarEnum[BarEnum["Bar"] = 1] = "Bar"; + })(exports.BarEnum || (exports.BarEnum = {})); + var BarEnum = exports.BarEnum; + ; + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.transpiled.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.transpiled.txt new file mode 100644 index 000000000..e15f0a852 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.transpiled.txt @@ -0,0 +1,6 @@ + Asset Size Chunks Chunk Names +bundle.js 1.87 kB 0 [emitted] main +chunk {0} bundle.js (main) 310 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 76 bytes {0} [built] + [1] ./.test/constEnumReExportWatch/foo.ts 77 bytes {0} [built] + [2] ./.test/constEnumReExportWatch/bar.ts 157 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.txt new file mode 100644 index 000000000..c3c074468 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/output.txt @@ -0,0 +1,4 @@ + Asset Size Chunks Chunk Names +bundle.js 1.43 kB 0 [emitted] main +chunk {0} bundle.js (main) 40 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 40 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.js new file mode 100644 index 000000000..f06a7bba3 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.js @@ -0,0 +1,52 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + "use strict"; + console.log(2 /* Bar */); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.transpiled.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.transpiled.js new file mode 100644 index 000000000..da935249f --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/bundle.transpiled.js @@ -0,0 +1,74 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var foo_1 = __webpack_require__(1); + console.log(foo_1.BarEnum.Bar); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var bar_1 = __webpack_require__(2); + exports.BarEnum = bar_1.BarEnum; + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + (function (BarEnum) { + BarEnum[BarEnum["Bar"] = 2] = "Bar"; + })(exports.BarEnum || (exports.BarEnum = {})); + var BarEnum = exports.BarEnum; + ; + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.transpiled.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.transpiled.txt new file mode 100644 index 000000000..63773d231 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.transpiled.txt @@ -0,0 +1,6 @@ + Asset Size Chunks Chunk Names +bundle.js 1.87 kB 0 [emitted] main +chunk {0} bundle.js (main) 310 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 76 bytes {0} + [1] ./.test/constEnumReExportWatch/foo.ts 77 bytes {0} + [2] ./.test/constEnumReExportWatch/bar.ts 157 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.txt new file mode 100644 index 000000000..c3c074468 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.1/patch0/output.txt @@ -0,0 +1,4 @@ + Asset Size Chunks Chunk Names +bundle.js 1.43 kB 0 [emitted] main +chunk {0} bundle.js (main) 40 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 40 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/foo.ts b/test/comparison-tests/constEnumReExportWatch/foo.ts new file mode 100644 index 000000000..9cffcfd47 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/foo.ts @@ -0,0 +1 @@ +export { BarEnum } from './bar'; diff --git a/test/comparison-tests/constEnumReExportWatch/patch0/bar.ts b/test/comparison-tests/constEnumReExportWatch/patch0/bar.ts new file mode 100644 index 000000000..5191feb7a --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/patch0/bar.ts @@ -0,0 +1,3 @@ +export const enum BarEnum { + Bar = 2 +}; diff --git a/test/comparison-tests/constEnumReExportWatch/tsconfig.json b/test/comparison-tests/constEnumReExportWatch/tsconfig.json new file mode 100644 index 000000000..586069afa --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + }, + "exclude": [ + "patch*" + ] +} \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/webpack.config.js b/test/comparison-tests/constEnumReExportWatch/webpack.config.js new file mode 100644 index 000000000..aae026d84 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/webpack.config.js @@ -0,0 +1,17 @@ +module.exports = { + entry: './app.ts', + output: { + filename: 'bundle.js' + }, + resolve: { + extensions: ['', '.ts', '.js'] + }, + module: { + loaders: [ + { test: /\.ts$/, loader: 'ts-loader' } + ] + } +} + +// for test harness purposes only, you would not need this in a normal project +module.exports.resolveLoader = { alias: { 'ts-loader': require('path').join(__dirname, "../../index.js") } } \ No newline at end of file From 9f226d0b6b875335dcc47fdf6705b0bc8f2b403a Mon Sep 17 00:00:00 2001 From: smphhh Date: Tue, 15 Nov 2016 15:37:19 +0200 Subject: [PATCH 2/5] Add expected TS 2.0 output for const enum test --- .../expectedOutput-2.0/bundle.js | 52 +++++++++++++ .../expectedOutput-2.0/bundle.transpiled.js | 74 +++++++++++++++++++ .../expectedOutput-2.0/output.transpiled.txt | 6 ++ .../expectedOutput-2.0/output.txt | 4 + .../expectedOutput-2.0/patch0/bundle.js | 52 +++++++++++++ .../patch0/bundle.transpiled.js | 74 +++++++++++++++++++ .../patch0/output.transpiled.txt | 6 ++ .../expectedOutput-2.0/patch0/output.txt | 4 + 8 files changed, 272 insertions(+) create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.transpiled.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.transpiled.txt create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.txt create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.transpiled.js create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.transpiled.txt create mode 100644 test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.txt diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.js new file mode 100644 index 000000000..492b6e7de --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.js @@ -0,0 +1,52 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + "use strict"; + console.log(1 /* Bar */); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.transpiled.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.transpiled.js new file mode 100644 index 000000000..41ffea88a --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/bundle.transpiled.js @@ -0,0 +1,74 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var foo_1 = __webpack_require__(1); + console.log(foo_1.BarEnum.Bar); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var bar_1 = __webpack_require__(2); + exports.BarEnum = bar_1.BarEnum; + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + (function (BarEnum) { + BarEnum[BarEnum["Bar"] = 1] = "Bar"; + })(exports.BarEnum || (exports.BarEnum = {})); + var BarEnum = exports.BarEnum; + ; + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.transpiled.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.transpiled.txt new file mode 100644 index 000000000..e15f0a852 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.transpiled.txt @@ -0,0 +1,6 @@ + Asset Size Chunks Chunk Names +bundle.js 1.87 kB 0 [emitted] main +chunk {0} bundle.js (main) 310 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 76 bytes {0} [built] + [1] ./.test/constEnumReExportWatch/foo.ts 77 bytes {0} [built] + [2] ./.test/constEnumReExportWatch/bar.ts 157 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.txt new file mode 100644 index 000000000..c3c074468 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/output.txt @@ -0,0 +1,4 @@ + Asset Size Chunks Chunk Names +bundle.js 1.43 kB 0 [emitted] main +chunk {0} bundle.js (main) 40 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 40 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.js new file mode 100644 index 000000000..f06a7bba3 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.js @@ -0,0 +1,52 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + "use strict"; + console.log(2 /* Bar */); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.transpiled.js b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.transpiled.js new file mode 100644 index 000000000..da935249f --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/bundle.transpiled.js @@ -0,0 +1,74 @@ +/******/ (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] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = 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; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var foo_1 = __webpack_require__(1); + console.log(foo_1.BarEnum.Bar); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var bar_1 = __webpack_require__(2); + exports.BarEnum = bar_1.BarEnum; + + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + (function (BarEnum) { + BarEnum[BarEnum["Bar"] = 2] = "Bar"; + })(exports.BarEnum || (exports.BarEnum = {})); + var BarEnum = exports.BarEnum; + ; + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.transpiled.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.transpiled.txt new file mode 100644 index 000000000..63773d231 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.transpiled.txt @@ -0,0 +1,6 @@ + Asset Size Chunks Chunk Names +bundle.js 1.87 kB 0 [emitted] main +chunk {0} bundle.js (main) 310 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 76 bytes {0} + [1] ./.test/constEnumReExportWatch/foo.ts 77 bytes {0} + [2] ./.test/constEnumReExportWatch/bar.ts 157 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.txt b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.txt new file mode 100644 index 000000000..c3c074468 --- /dev/null +++ b/test/comparison-tests/constEnumReExportWatch/expectedOutput-2.0/patch0/output.txt @@ -0,0 +1,4 @@ + Asset Size Chunks Chunk Names +bundle.js 1.43 kB 0 [emitted] main +chunk {0} bundle.js (main) 40 bytes [rendered] + [0] ./.test/constEnumReExportWatch/app.ts 40 bytes {0} [built] \ No newline at end of file From 7c442c44dc7b1abaa0a3126e914f8052a3a1c1e8 Mon Sep 17 00:00:00 2001 From: smphhh Date: Tue, 15 Nov 2016 22:43:01 +0200 Subject: [PATCH 3/5] Add deep file dependencies to webpack --- src/after-compile.ts | 24 +---------------------- src/index.ts | 5 +++-- src/interfaces.ts | 2 +- src/utils.ts | 45 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/after-compile.ts b/src/after-compile.ts index 27f47b0a1..7497f67bf 100644 --- a/src/after-compile.ts +++ b/src/after-compile.ts @@ -100,7 +100,7 @@ function determineFilesToCheckForErrors( } else if (modifiedFiles) { // check all modified files, and all dependants Object.keys(modifiedFiles).forEach(modifiedFileName => { - collectAllDependants(instance.reverseDependencyGraph, modifiedFileName) + utils.collectAllDependants(instance.reverseDependencyGraph, modifiedFileName) .forEach(fileName => { filesToCheckForErrors[fileName] = files[fileName]; }); @@ -193,26 +193,4 @@ function removeTSLoaderErrors(errors: interfaces.WebpackError[]) { } } -/** - * Recursively collect all possible dependants of passed file - */ -function collectAllDependants( - reverseDependencyGraph: interfaces.ReverseDependencyGraph, - fileName: string, - collected: {[file:string]: boolean} = {} -): string[] { - const result = {}; - result[fileName] = true; - collected[fileName] = true; - if (reverseDependencyGraph[fileName]) { - Object.keys(reverseDependencyGraph[fileName]).forEach(dependantFileName => { - if (!collected[dependantFileName]) { - collectAllDependants(reverseDependencyGraph, dependantFileName, collected) - .forEach(fName => result[fName] = true); - } - }); - } - return Object.keys(result); -} - export = makeAfterCompile; diff --git a/src/index.ts b/src/index.ts index 5ae815163..cb6bcee76 100644 --- a/src/index.ts +++ b/src/index.ts @@ -110,8 +110,9 @@ function getEmit( const allDefinitionFiles = Object.keys(instance.files).filter(fp => definitionFileRegex.test(fp)); allDefinitionFiles.forEach(loader.addDependency.bind(loader)); - // Additionally make this file dependent on all imported files - let additionalDependencies = instance.dependencyGraph[filePath]; + // Additionally make this file dependent on all imported files as well + // as any deeper recursive dependencies + let additionalDependencies = utils.collectAllDependencies(instance.dependencyGraph, filePath, {}); if (additionalDependencies) { additionalDependencies.forEach(loader.addDependency.bind(loader)); } diff --git a/src/interfaces.ts b/src/interfaces.ts index bde2564bd..6ad48ec74 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -133,7 +133,7 @@ export interface TSInstances { [name: string]: TSInstance; } -interface DependencyGraph { +export interface DependencyGraph { [file: string]: string[]; } diff --git a/src/utils.ts b/src/utils.ts index c74876464..fdaee3696 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -86,3 +86,48 @@ export function appendTsSuffixIfMatch(patterns: RegExp[], path: string): string } return path; } + +/** + * Recursively collect all possible dependants of passed file + */ +export function collectAllDependants( + reverseDependencyGraph: interfaces.ReverseDependencyGraph, + fileName: string, + collected: {[file:string]: boolean} = {} +): string[] { + const result = {}; + result[fileName] = true; + collected[fileName] = true; + if (reverseDependencyGraph[fileName]) { + Object.keys(reverseDependencyGraph[fileName]).forEach(dependantFileName => { + if (!collected[dependantFileName]) { + collectAllDependants(reverseDependencyGraph, dependantFileName, collected) + .forEach(fName => result[fName] = true); + } + }); + } + return Object.keys(result); +} + +/** + * Recursively collect all possible dependencies of passed file + */ +export function collectAllDependencies( + dependencyGraph: interfaces.DependencyGraph, + filePath: string, + collected: {[file:string]: boolean} = {} +): string[] { + const result = {}; + result[filePath] = true; + collected[filePath] = true; + let directDependencies = dependencyGraph[filePath]; + if (directDependencies) { + directDependencies.forEach(dependencyFilePath => { + if (!collected[dependencyFilePath]) { + collectAllDependencies(dependencyGraph, dependencyFilePath, collected) + .forEach(fPath => result[fPath] = true); + } + }); + } + return Object.keys(result); +} From 938e922ea1b032c40485be1103bc1479c85f2bc9 Mon Sep 17 00:00:00 2001 From: smphhh Date: Tue, 15 Nov 2016 22:43:44 +0200 Subject: [PATCH 4/5] Accept new test output --- .../simpleDependency/expectedOutput-1.6/patch0/output.txt | 2 +- .../simpleDependency/expectedOutput-1.6/patch1/output.txt | 2 +- .../simpleDependency/expectedOutput-1.7/patch0/output.txt | 2 +- .../simpleDependency/expectedOutput-1.7/patch1/output.txt | 2 +- .../simpleDependency/expectedOutput-1.8/patch0/output.txt | 2 +- .../simpleDependency/expectedOutput-1.8/patch1/output.txt | 2 +- .../simpleDependency/expectedOutput-2.0/patch0/output.txt | 2 +- .../simpleDependency/expectedOutput-2.0/patch1/output.txt | 2 +- .../simpleDependency/expectedOutput-2.1/patch0/output.txt | 2 +- .../simpleDependency/expectedOutput-2.1/patch1/output.txt | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch0/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch0/output.txt index d8cc2e4cd..6bf873681 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch0/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch0/output.txt @@ -1,7 +1,7 @@ Asset Size Chunks Chunk Names bundle.js 1.71 kB 0 [emitted] main chunk {0} bundle.js (main) 155 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 37 bytes {0} [1 error] + [0] ./.test/simpleDependency/app.ts 37 bytes {0} [built] [1 error] [1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built] diff --git a/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch1/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch1/output.txt index 57d5a9d2f..0c369aa44 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch1/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-1.6/patch1/output.txt @@ -1,6 +1,6 @@ Asset Size Chunks Chunk Names bundle.js 1.71 kB 0 [emitted] main chunk {0} bundle.js (main) 155 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 37 bytes {0} + [0] ./.test/simpleDependency/app.ts 37 bytes {0} [built] [1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch0/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch0/output.txt index d8cc2e4cd..6bf873681 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch0/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch0/output.txt @@ -1,7 +1,7 @@ Asset Size Chunks Chunk Names bundle.js 1.71 kB 0 [emitted] main chunk {0} bundle.js (main) 155 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 37 bytes {0} [1 error] + [0] ./.test/simpleDependency/app.ts 37 bytes {0} [built] [1 error] [1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built] diff --git a/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch1/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch1/output.txt index 57d5a9d2f..0c369aa44 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch1/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-1.7/patch1/output.txt @@ -1,6 +1,6 @@ Asset Size Chunks Chunk Names bundle.js 1.71 kB 0 [emitted] main chunk {0} bundle.js (main) 155 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 37 bytes {0} + [0] ./.test/simpleDependency/app.ts 37 bytes {0} [built] [1] ./.test/simpleDependency/dep.ts 56 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 62 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch0/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch0/output.txt index c5aaf6705..eec01eaa8 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch0/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch0/output.txt @@ -1,7 +1,7 @@ Asset Size Chunks Chunk Names bundle.js 1.75 kB 0 [emitted] main chunk {0} bundle.js (main) 197 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 51 bytes {0} [1 error] + [0] ./.test/simpleDependency/app.ts 51 bytes {0} [built] [1 error] [1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built] diff --git a/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch1/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch1/output.txt index 038e84f63..a68e8e4a5 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch1/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-1.8/patch1/output.txt @@ -1,6 +1,6 @@ Asset Size Chunks Chunk Names bundle.js 1.75 kB 0 [emitted] main chunk {0} bundle.js (main) 197 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 51 bytes {0} + [0] ./.test/simpleDependency/app.ts 51 bytes {0} [built] [1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch0/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch0/output.txt index c5aaf6705..eec01eaa8 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch0/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch0/output.txt @@ -1,7 +1,7 @@ Asset Size Chunks Chunk Names bundle.js 1.75 kB 0 [emitted] main chunk {0} bundle.js (main) 197 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 51 bytes {0} [1 error] + [0] ./.test/simpleDependency/app.ts 51 bytes {0} [built] [1 error] [1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built] diff --git a/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch1/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch1/output.txt index 038e84f63..a68e8e4a5 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch1/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-2.0/patch1/output.txt @@ -1,6 +1,6 @@ Asset Size Chunks Chunk Names bundle.js 1.75 kB 0 [emitted] main chunk {0} bundle.js (main) 197 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 51 bytes {0} + [0] ./.test/simpleDependency/app.ts 51 bytes {0} [built] [1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch0/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch0/output.txt index c17084c0f..11f7260ad 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch0/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch0/output.txt @@ -1,7 +1,7 @@ Asset Size Chunks Chunk Names bundle.js 1.75 kB 0 [emitted] main chunk {0} bundle.js (main) 197 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 51 bytes {0} [1 error] + [0] ./.test/simpleDependency/app.ts 51 bytes {0} [built] [1 error] [1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built] diff --git a/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch1/output.txt b/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch1/output.txt index 038e84f63..a68e8e4a5 100644 --- a/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch1/output.txt +++ b/test/comparison-tests/simpleDependency/expectedOutput-2.1/patch1/output.txt @@ -1,6 +1,6 @@ Asset Size Chunks Chunk Names bundle.js 1.75 kB 0 [emitted] main chunk {0} bundle.js (main) 197 bytes [rendered] - [0] ./.test/simpleDependency/app.ts 51 bytes {0} + [0] ./.test/simpleDependency/app.ts 51 bytes {0} [built] [1] ./.test/simpleDependency/dep.ts 70 bytes {0} [built] [2] ./.test/simpleDependency/deeperDep.ts 76 bytes {0} [built] \ No newline at end of file From b2528ed3ead4314d9131fb9496a74890630f7090 Mon Sep 17 00:00:00 2001 From: smphhh Date: Tue, 15 Nov 2016 22:45:57 +0200 Subject: [PATCH 5/5] Remove redundant function argument --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index cb6bcee76..94be634d1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -112,7 +112,7 @@ function getEmit( // Additionally make this file dependent on all imported files as well // as any deeper recursive dependencies - let additionalDependencies = utils.collectAllDependencies(instance.dependencyGraph, filePath, {}); + let additionalDependencies = utils.collectAllDependencies(instance.dependencyGraph, filePath); if (additionalDependencies) { additionalDependencies.forEach(loader.addDependency.bind(loader)); }