Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@ function loader(contents) {
// Make this file dependent on *all* definition files in the program
this.clearDependencies();
this.addDependency(filePath);
Object.keys(instance.files).filter(filePath => !!filePath.match(/\.d\.ts$/)).forEach(this.addDependency.bind(this));

let allDefinitionFiles = Object.keys(instance.files).filter(filePath => /\.d\.ts$/.test(filePath));
allDefinitionFiles.forEach(this.addDependency.bind(this));
this._module.meta.tsLoaderDefinitionFileVersions = allDefinitionFiles.map(filePath => filePath+'@'+instance.files[filePath].version);

// Emit Javascript
var output = langService.getEmitOutput(filePath);
Expand All @@ -581,7 +584,7 @@ function loader(contents) {
// Make sure webpack is aware that even though the emitted JavaScript may be the same as
// a previously cached version the TypeScript may be different and therefore should be
// treated as new
this._module.meta['tsLoaderFileVersion'] = file.version;
this._module.meta.tsLoaderFileVersion = file.version;

callback(null, outputText, sourceMap)
}
Expand Down
61 changes: 61 additions & 0 deletions test/declarationWatch/expectedOutput/patch0/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/******/ (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__) {

var dep = __webpack_require__(1);
console.log(dep);
Thing.doSomething();


/***/ },
/* 1 */
/***/ function(module, exports) {

Thing.doSomething();
module.exports = 'dep';


/***/ }
/******/ ]);
6 changes: 3 additions & 3 deletions test/declarationWatch/expectedOutput/patch0/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Asset Size Chunks Chunk Names
bundle.js 1.58 kB 0 main
chunk {0} bundle.js (main) 112 bytes
Asset Size Chunks Chunk Names
bundle.js 1.58 kB 0 [emitted] main
chunk {0} bundle.js (main) 112 bytes [rendered]
[0] ./.test/declarationWatch/app.ts 67 bytes {0} [built] [1 error]
[1] ./.test/declarationWatch/dep.ts 45 bytes {0} [built] [1 error]

Expand Down
61 changes: 61 additions & 0 deletions test/declarationWatch/expectedOutput/patch1/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/******/ (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__) {

var dep = __webpack_require__(1);
console.log(dep);
Thing.doSomething();


/***/ },
/* 1 */
/***/ function(module, exports) {

Thing.doSomething();
module.exports = 'dep';


/***/ }
/******/ ]);
6 changes: 3 additions & 3 deletions test/declarationWatch/expectedOutput/patch1/output.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Asset Size Chunks Chunk Names
bundle.js 1.58 kB 0 main
chunk {0} bundle.js (main) 112 bytes
Asset Size Chunks Chunk Names
bundle.js 1.58 kB 0 [emitted] main
chunk {0} bundle.js (main) 112 bytes [rendered]
[0] ./.test/declarationWatch/app.ts 67 bytes {0} [built]
[1] ./.test/declarationWatch/dep.ts 45 bytes {0} [built]
2 changes: 1 addition & 1 deletion test/issue81/expectedOutput/bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function createTest(test, testPath, options) {
if (options.transpile) config.ts.transpileOnly = true;

var iteration = 0;
var lastHash;
var watcher = webpack(config).watch({aggregateTimeout: 1500}, function(err, stats) {
var patch = '';
if (iteration > 0) {
Expand All @@ -106,6 +107,16 @@ function createTest(test, testPath, options) {
if (saveOutputMode) mkdirp.sync(originalExpectedOutput);
}

// replace the hash if found in the output since it can change depending
// on environments and we're not super interested in it
if (stats) {
fs.readdirSync(webpackOutput).forEach(function(file) {
var content = fs.readFileSync(path.join(webpackOutput, file), 'utf-8');
content = content.split(stats.hash).join('[hash]');
fs.writeFileSync(path.join(webpackOutput, file), content);
});
}

// output results
if (saveOutputMode) {
// loop through webpackOutput and rename to .transpiled if needed
Expand Down Expand Up @@ -154,7 +165,9 @@ function createTest(test, testPath, options) {
}
}

if (stats) {
if (stats && stats.hash != lastHash) {
lastHash = stats.hash;

var statsFileName = 'output.txt';

var statsString = stats.toString({timings: false, version: false, hash: false})
Expand Down
2 changes: 1 addition & 1 deletion test/sourceMaps/expectedOutput/bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.