From ac07799e2a333b8b7e5740c5ffd312a2213b05b0 Mon Sep 17 00:00:00 2001 From: Will Martin Date: Tue, 5 Sep 2017 13:51:09 -0700 Subject: [PATCH 1/4] Force typescript version to be 2.4.2 This should not be merged in but with new typescript updates there are type issues for a clean initial build. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9503e8d2f..fbe210982 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "mkdirp": "^0.5.1", "mocha": "^3.1.0", "rimraf": "^2.4.2", - "typescript": "^2.4.0", + "typescript": "2.4.2", "typings": "^2.0.0", "webpack": "^2.2.0" } From 9e7062dad83c5582256b3924a4ae67a4fea39e62 Mon Sep 17 00:00:00 2001 From: Will Martin Date: Tue, 5 Sep 2017 14:12:51 -0700 Subject: [PATCH 2/4] Add check if the resolvedModule is a js file before reusing isExternalLibraryImport Passes all current tests. Still need to add a new one for this (works locally). --- src/servicesHost.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/servicesHost.ts b/src/servicesHost.ts index 4f65fb2ed..354314877 100644 --- a/src/servicesHost.ts +++ b/src/servicesHost.ts @@ -112,6 +112,14 @@ function resolveModuleNames( return resolvedModules; } +function isJsImplementationOfTypings( + resolvedModule: ResolvedModule, + tsResolution: ResolvedModule +) { + return resolvedModule.resolvedFileName.endsWith('js') && + /node_modules(\\|\/).*\.d\.ts$/.test(tsResolution.resolvedFileName); +} + function resolveModuleName( resolveSync: ResolveSync, moduleResolutionHost: ModuleResolutionHost, @@ -153,7 +161,7 @@ function resolveModuleName( }; if (resolutionResult!) { if (resolutionResult!.resolvedFileName === tsResolutionResult.resolvedFileName || - /node_modules(\\|\/).*\.d\.ts$/.test(tsResolutionResult.resolvedFileName)) { + isJsImplementationOfTypings(resolutionResult!, tsResolutionResult)) { resolutionResult!.isExternalLibraryImport = tsResolutionResult.isExternalLibraryImport; } } else { From 4f0d400092a6e6b84c22243c9626c9ae8507b249 Mon Sep 17 00:00:00 2001 From: Will Martin Date: Tue, 5 Sep 2017 15:01:49 -0700 Subject: [PATCH 3/4] Add test for change --- .../localTsImplementationOfTypings/app.ts | 3 + .../expectedOutput-2.4/bundle.js | 94 +++++++++++++++++++ .../expectedOutput-2.4/output.txt | 5 + .../localTsImplementationOfTypings/fake.ts | 3 + .../tsconfig.json | 8 ++ .../webpack.config.js | 21 +++++ 6 files changed, 134 insertions(+) create mode 100644 test/comparison-tests/localTsImplementationOfTypings/app.ts create mode 100644 test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/bundle.js create mode 100644 test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/output.txt create mode 100644 test/comparison-tests/localTsImplementationOfTypings/fake.ts create mode 100644 test/comparison-tests/localTsImplementationOfTypings/tsconfig.json create mode 100644 test/comparison-tests/localTsImplementationOfTypings/webpack.config.js diff --git a/test/comparison-tests/localTsImplementationOfTypings/app.ts b/test/comparison-tests/localTsImplementationOfTypings/app.ts new file mode 100644 index 000000000..35b15ee38 --- /dev/null +++ b/test/comparison-tests/localTsImplementationOfTypings/app.ts @@ -0,0 +1,3 @@ +import myComponent = require('api'); + +console.log(myComponent); \ No newline at end of file diff --git a/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/bundle.js b/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/bundle.js new file mode 100644 index 000000000..83e40072b --- /dev/null +++ b/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/bundle.js @@ -0,0 +1,94 @@ +/******/ (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 = 1); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +exports.__esModule = true; +function sayHello(name) { + return "Hello, " + name + "!"; +} +exports.sayHello = sayHello; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +exports.__esModule = true; +var myComponent = __webpack_require__(0); +console.log(myComponent); + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/output.txt b/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/output.txt new file mode 100644 index 000000000..c8da62da4 --- /dev/null +++ b/test/comparison-tests/localTsImplementationOfTypings/expectedOutput-2.4/output.txt @@ -0,0 +1,5 @@ + Asset Size Chunks Chunk Names +bundle.js 2.98 kB 0 [emitted] main +chunk {0} bundle.js (main) 234 bytes [entry] [rendered] + [0] ./.test/localTsImplementationOfTypings/fake.ts 133 bytes {0} [built] + [1] ./.test/localTsImplementationOfTypings/app.ts 101 bytes {0} [built] \ No newline at end of file diff --git a/test/comparison-tests/localTsImplementationOfTypings/fake.ts b/test/comparison-tests/localTsImplementationOfTypings/fake.ts new file mode 100644 index 000000000..2af138a6a --- /dev/null +++ b/test/comparison-tests/localTsImplementationOfTypings/fake.ts @@ -0,0 +1,3 @@ +export function sayHello(name: string): string { + return `Hello, ${name}!`; +} \ No newline at end of file diff --git a/test/comparison-tests/localTsImplementationOfTypings/tsconfig.json b/test/comparison-tests/localTsImplementationOfTypings/tsconfig.json new file mode 100644 index 000000000..8ed5d221a --- /dev/null +++ b/test/comparison-tests/localTsImplementationOfTypings/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + + }, + "include": [ + "app.ts" + ] +} \ No newline at end of file diff --git a/test/comparison-tests/localTsImplementationOfTypings/webpack.config.js b/test/comparison-tests/localTsImplementationOfTypings/webpack.config.js new file mode 100644 index 000000000..5af429788 --- /dev/null +++ b/test/comparison-tests/localTsImplementationOfTypings/webpack.config.js @@ -0,0 +1,21 @@ +var path = require('path'); + +module.exports = { + entry: './app.ts', + output: { + filename: 'bundle.js' + }, + resolve: { + alias: { + api: path.resolve(__dirname, 'fake') + }, + extensions: ['.ts', '.js'] + }, + module: { + rules: [ + { test: /\.ts$/, loader: 'ts-loader' } + ] + } +} + + From 287e74752f4aa3be0908a0ee2c186113101746b3 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 6 Sep 2017 14:27:14 +0100 Subject: [PATCH 4/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fbe210982..4c952bfb9 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "mkdirp": "^0.5.1", "mocha": "^3.1.0", "rimraf": "^2.4.2", - "typescript": "2.4.2", + "typescript": "^2.4.2", "typings": "^2.0.0", "webpack": "^2.2.0" }