Skip to content

Commit 8ab5b26

Browse files
committed
add test for issue #388
1 parent 3490ca6 commit 8ab5b26

File tree

14 files changed

+137
-2
lines changed

14 files changed

+137
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"build": "tsc --version && tsc --project \"./src\"",
8-
"comparison-tests": "npm link ./test/comparison-tests/testLib && node test/comparison-tests/run-tests.js",
8+
"comparison-tests": "npm link ./test/comparison-tests/testLib && npm link ./test/comparison-tests/testLibIssue388 && node test/comparison-tests/run-tests.js",
99
"execution-tests": "node test/execution-tests/run-tests.js",
1010
"test": "node test/run-tests.js"
1111
},

test/comparison-tests/create-and-execute-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var stagingPath = path.resolve(rootPath, '.test');
3838
var testPath = path.join(__dirname, testToRun);
3939
var testIsFlaky = pathExists(path.join(testPath, FLAKY));
4040
if (fs.statSync(testPath).isDirectory() &&
41-
testToRun !== 'testLib') {
41+
testToRun !== 'testLib' && testToRun !== 'testLibIssue388') {
4242

4343
describe(testToRun, function () {
4444
it('should have the correct output', createTest(testToRun, testPath, {}));

test/comparison-tests/issue388/app.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { foo } from 'libissue388';
2+
3+
console.log(foo());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
"use strict";
48+
var libissue388_1 = __webpack_require__(1);
49+
console.log(libissue388_1.foo());
50+
51+
52+
/***/ },
53+
/* 1 */
54+
/***/ function(module, exports, __webpack_require__) {
55+
56+
var populateClientExports = __webpack_require__(2).populateClientExports;
57+
populateClientExports(exports);
58+
59+
/***/ },
60+
/* 2 */
61+
/***/ function(module, exports, __webpack_require__) {
62+
63+
function populateClientExports(exports) {
64+
exports.foo = __webpack_require__(3).foo;
65+
}
66+
exports.populateClientExports = populateClientExports;
67+
68+
/***/ },
69+
/* 3 */
70+
/***/ function(module, exports) {
71+
72+
function foo() {
73+
return 'foo';
74+
}
75+
76+
exports.foo = foo;
77+
78+
/***/ }
79+
/******/ ]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Asset Size Chunks Chunk Names
2+
bundle.js 2.02 kB 0 [emitted] main
3+
chunk {0} bundle.js (main) 395 bytes [rendered]
4+
[0] ./.test/issue388/app.ts 92 bytes {0} [built]
5+
[1] ./test/comparison-tests/testLibIssue388/main.js 109 bytes {0} [built]
6+
[2] ./test/comparison-tests/testLibIssue388/clientExports.js 138 bytes {0} [built]
7+
[3] ./test/comparison-tests/testLibIssue388/foo.js 56 bytes {0} [built]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"allowJs": true
5+
}
6+
}
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") } }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function populateClientExports(exports: any): void;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function populateClientExports(exports) {
2+
exports.foo = require('./foo').foo;
3+
}
4+
exports.populateClientExports = populateClientExports;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function foo(): string;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function foo() {
2+
return 'foo';
3+
}
4+
5+
exports.foo = foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './foo';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var populateClientExports = require('./clientExports').populateClientExports;
2+
populateClientExports(exports);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "libissue388",
3+
"version": "0.0.1",
4+
"description": "Dummy lib for issue 388 testing for ts-loader",
5+
"main": "./main.js",
6+
"typings": "./main.d.ts"
7+
}

0 commit comments

Comments
 (0)