diff --git a/README.md b/README.md index 7a37e1f59..af92202db 100644 --- a/README.md +++ b/README.md @@ -250,6 +250,8 @@ You may provide * a relative path to the configuration file. It will be resolved relative to the respective `.ts` entry file. * an absolute path to the configuration file. +Note that TypeScript only accepts source files inside the project root. By default, the project root will be the folder that holds your config file. You can modify it by setting the [`rootDir`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) TypeScript option in your configuration. + #### visualStudioErrorFormat *(boolean) (default=false)* If `true`, the TypeScript compiler output for an error or a warning, e.g. `(3,14): error TS4711: you did something very wrong`, in file `myFile` will instead be `myFile(3,14): error TS4711: you did something very wrong` (notice the file name at the beginning). This way Visual Studio will interpret this line and show any errors or warnings in the *error list*. This enables navigation to the file/line/column through double click. diff --git a/src/config.ts b/src/config.ts index 09c53ca93..0fd89fac1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -121,19 +121,40 @@ export function getConfigParseResult( configFile: ConfigFile, configFilePath: string ) { + let basePath: string + const configDir = path.dirname(configFilePath || '') + + // check for `compilerOptions.rootDir` + if (configFile.config.compilerOptions && typeof configFile.config.compilerOptions.rootDir === 'string') { + const configuredRootDir = configFile.config.compilerOptions.rootDir + + // `rootDir` is absolute -> use it as `basePath` + if (path.isAbsolute(configuredRootDir)) { + basePath = configuredRootDir + + // `rootDir` is relative -> resolve it relative to config dir + } else { + basePath = path.resolve(configDir, configuredRootDir) + } + + // no `rootDir` -> use config directory as `basePath` + } else { + basePath = configDir + } + let configParseResult: typescript.ParsedCommandLine; if (typeof ( compiler).parseJsonConfigFileContent === 'function') { // parseConfigFile was renamed between 1.6.2 and 1.7 configParseResult = (/**/ compiler).parseJsonConfigFileContent( configFile.config, compiler.sys, - path.dirname(configFilePath || '') + basePath ); } else { configParseResult = (/**/ compiler).parseConfigFile( configFile.config, compiler.sys, - path.dirname(configFilePath || '') + basePath ); } diff --git a/test/comparison-tests/configureRoot/.DS_Store b/test/comparison-tests/configureRoot/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/test/comparison-tests/configureRoot/.DS_Store differ diff --git a/test/comparison-tests/configureRoot/config/tsconfig.json b/test/comparison-tests/configureRoot/config/tsconfig.json new file mode 100644 index 000000000..a5bdb806f --- /dev/null +++ b/test/comparison-tests/configureRoot/config/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "rootDir": ".." + } +} \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-1.6/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-1.6/bundle.js new file mode 100644 index 000000000..58ea3820b --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-1.6/bundle.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] = { +/******/ 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, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +console.log('Hello world'); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-1.6/output.txt b/test/comparison-tests/configureRoot/expectedOutput-1.6/output.txt new file mode 100644 index 000000000..1baccb494 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-1.6/output.txt @@ -0,0 +1,3 @@ + Asset Size Chunks Chunk Names +bundle.js 2.5 kB 0 [emitted] main + [0] ./index.ts 28 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-1.7/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-1.7/bundle.js new file mode 100644 index 000000000..58ea3820b --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-1.7/bundle.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] = { +/******/ 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, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +console.log('Hello world'); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-1.7/output.txt b/test/comparison-tests/configureRoot/expectedOutput-1.7/output.txt new file mode 100644 index 000000000..1baccb494 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-1.7/output.txt @@ -0,0 +1,3 @@ + Asset Size Chunks Chunk Names +bundle.js 2.5 kB 0 [emitted] main + [0] ./index.ts 28 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-1.8/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-1.8/bundle.js new file mode 100644 index 000000000..58ea3820b --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-1.8/bundle.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] = { +/******/ 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, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +console.log('Hello world'); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-1.8/output.txt b/test/comparison-tests/configureRoot/expectedOutput-1.8/output.txt new file mode 100644 index 000000000..1baccb494 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-1.8/output.txt @@ -0,0 +1,3 @@ + Asset Size Chunks Chunk Names +bundle.js 2.5 kB 0 [emitted] main + [0] ./index.ts 28 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.0/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-2.0/bundle.js new file mode 100644 index 000000000..58ea3820b --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.0/bundle.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] = { +/******/ 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, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +console.log('Hello world'); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.0/output.txt b/test/comparison-tests/configureRoot/expectedOutput-2.0/output.txt new file mode 100644 index 000000000..1baccb494 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.0/output.txt @@ -0,0 +1,3 @@ + Asset Size Chunks Chunk Names +bundle.js 2.5 kB 0 [emitted] main + [0] ./index.ts 28 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.1/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-2.1/bundle.js new file mode 100644 index 000000000..58ea3820b --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.1/bundle.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] = { +/******/ 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, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +console.log('Hello world'); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.1/output.txt b/test/comparison-tests/configureRoot/expectedOutput-2.1/output.txt new file mode 100644 index 000000000..1baccb494 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.1/output.txt @@ -0,0 +1,3 @@ + Asset Size Chunks Chunk Names +bundle.js 2.5 kB 0 [emitted] main + [0] ./index.ts 28 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.2/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-2.2/bundle.js new file mode 100644 index 000000000..58ea3820b --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.2/bundle.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] = { +/******/ 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, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +console.log('Hello world'); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.2/output.txt b/test/comparison-tests/configureRoot/expectedOutput-2.2/output.txt new file mode 100644 index 000000000..1baccb494 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.2/output.txt @@ -0,0 +1,3 @@ + Asset Size Chunks Chunk Names +bundle.js 2.5 kB 0 [emitted] main + [0] ./index.ts 28 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.3/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-2.3/bundle.js new file mode 100644 index 000000000..58ea3820b --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.3/bundle.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] = { +/******/ 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, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +console.log('Hello world'); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.3/output.txt b/test/comparison-tests/configureRoot/expectedOutput-2.3/output.txt new file mode 100644 index 000000000..1baccb494 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.3/output.txt @@ -0,0 +1,3 @@ + Asset Size Chunks Chunk Names +bundle.js 2.5 kB 0 [emitted] main + [0] ./index.ts 28 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.4/bundle.js b/test/comparison-tests/configureRoot/expectedOutput-2.4/bundle.js new file mode 100644 index 000000000..b3736f86f --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.4/bundle.js @@ -0,0 +1,76 @@ +/******/ (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; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // 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 = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +throw new Error("Module build failed: \u001b[31merror while parsing tsconfig.json\u001b[39m"); + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/expectedOutput-2.4/output.txt b/test/comparison-tests/configureRoot/expectedOutput-2.4/output.txt new file mode 100644 index 000000000..a5a56f8e7 --- /dev/null +++ b/test/comparison-tests/configureRoot/expectedOutput-2.4/output.txt @@ -0,0 +1,9 @@ + Asset Size Chunks Chunk Names +bundle.js 2.73 kB 0 [emitted] main +chunk {0} bundle.js (main) 94 bytes [entry] [rendered] + [0] ./.test/configureRoot/index.ts 94 bytes {0} [built] [failed] [2 errors] + +ERROR in error TS18002: The 'files' list in config file 'tsconfig.json' is empty. + +ERROR in ./.test/configureRoot/index.ts +Module build failed: error while parsing tsconfig.json \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/index.ts b/test/comparison-tests/configureRoot/index.ts new file mode 100644 index 000000000..f5bda8dad --- /dev/null +++ b/test/comparison-tests/configureRoot/index.ts @@ -0,0 +1 @@ +console.log('Hello world') \ No newline at end of file diff --git a/test/comparison-tests/configureRoot/webpack.config.js b/test/comparison-tests/configureRoot/webpack.config.js new file mode 100644 index 000000000..b93400cf0 --- /dev/null +++ b/test/comparison-tests/configureRoot/webpack.config.js @@ -0,0 +1,25 @@ +module.exports = { + entry: './index', + output: { + filename: 'bundle.js' + }, + resolve: { + extensions: ['.ts'] + }, + module: { + rules: [{ + test: /\.ts$/, + exclude: /node_modules/, + use: [ + { + loader: 'ts-loader', + options: { + configFile: './config/tsconfig.json' + } + } + ] + }] + } +} + +