Skip to content

Commit eaf96cd

Browse files
committed
Fix issue with getScriptFileNames (#71)
1 parent c1e47ce commit eaf96cd

File tree

11 files changed

+115
-1
lines changed

11 files changed

+115
-1
lines changed

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function ensureTypeScriptInstance(options: Options, loader: any): { instance?: T
271271

272272
// Create the TypeScript language service
273273
var servicesHost = {
274-
getScriptFileNames: () => Object.keys(files),
274+
getScriptFileNames: () => Object.keys(files).filter(filePath => !!filePath.match(/(\.d)?\.tsx?$/)),
275275
getScriptVersion: fileName => {
276276
fileName = path.normalize(fileName);
277277
return files[fileName] && files[fileName].version.toString();

test/issue71/app.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import a = require('a');
2+
import b = require('./b');
3+
4+
console.log(a);
5+
console.log(b);

test/issue71/b.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export = 'b';

test/issue71/expectedOutput/bundle.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId])
10+
/******/ return installedModules[moduleId].exports;
11+
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ exports: {},
15+
/******/ id: moduleId,
16+
/******/ loaded: false
17+
/******/ };
18+
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
22+
/******/ // Flag the module as loaded
23+
/******/ module.loaded = true;
24+
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
29+
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
36+
/******/ // __webpack_public_path__
37+
/******/ __webpack_require__.p = "";
38+
39+
/******/ // Load entry module and return exports
40+
/******/ return __webpack_require__(0);
41+
/******/ })
42+
/************************************************************************/
43+
/******/ ([
44+
/* 0 */
45+
/***/ function(module, exports, __webpack_require__) {
46+
47+
var a = __webpack_require__(1);
48+
var b = __webpack_require__(2);
49+
console.log(a);
50+
console.log(b);
51+
52+
53+
/***/ },
54+
/* 1 */
55+
/***/ function(module, exports) {
56+
57+
module.exports = 'a';
58+
59+
/***/ },
60+
/* 2 */
61+
/***/ function(module, exports) {
62+
63+
module.exports = 'b';
64+
65+
66+
/***/ }
67+
/******/ ]);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Asset Size Chunks Chunk Names
2+
bundle.js 1.66 kB 0 [emitted] main
3+
chunk {0} bundle.js (main) 121 bytes [rendered]
4+
[0] ./.test/issue71/app.ts 78 bytes {0} [built]
5+
[1] ./.test/issue71/~/a/index.js 21 bytes {0} [built]
6+
[2] ./.test/issue71/b.ts 22 bytes {0} [built]

test/issue71/node_modules/a/a.d.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/issue71/node_modules/a/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/issue71/node_modules/a/package.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/issue71/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"noEmitOnError": true
4+
},
5+
"files": [
6+
]
7+
}

test/issue71/webpack.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var path = require('path')
2+
3+
module.exports = {
4+
entry: './app.ts',
5+
output: {
6+
filename: 'bundle.js'
7+
},
8+
resolve: {
9+
extensions: ['', '.ts', '.js']
10+
},
11+
module: {
12+
loaders: [
13+
{ test: /\.ts$/, loader: 'ts-loader' }
14+
]
15+
}
16+
}
17+
18+
// for test harness purposes only, you would not need this in a normal project
19+
module.exports.resolveLoader = { alias: { 'ts-loader': require('path').join(__dirname, "../../index.js") } }

test/run.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ fs.readdirSync(__dirname).forEach(function(test) {
3131
if (test == 'jsxPreserve' && semver.lt(typescript.version, '1.6.0-0')) return;
3232
if (test == 'es6codeSplitting' && semver.lt(typescript.version, '1.6.0-0')) return;
3333
if (test == 'nodeResolution' && semver.lt(typescript.version, '1.6.0-0')) return;
34+
if (test == 'issue71' && semver.lt(typescript.version, '1.6.0-0')) return;
3435

3536
describe(test, function() {
3637
it('should have the correct output', createTest(test, testPath, {}));
3738

3839
if (test == 'declarationOutput') { return; }
3940
if (test == 'declarationWatch') { return; }
4041
if (test == 'sourceMaps' && semver.lt(typescript.version, '1.6.0-0')) return;
42+
if (test == 'issue71') { return; }
4143
it('should work with transpile', createTest(test, testPath, {transpile: true}));
4244
});
4345
}

0 commit comments

Comments
 (0)