From 4aef5f43f10d535fdf9bc20ff9a08b446ac24926 Mon Sep 17 00:00:00 2001 From: arusakov Date: Mon, 19 Dec 2016 13:45:52 +0300 Subject: [PATCH 1/6] Use native Object.assign() --- .travis.yml | 2 ++ package.json | 4 +++- src/compilerSetup.ts | 3 +-- src/config.ts | 3 +-- src/index.ts | 5 ++--- src/tsconfig.json | 4 ++++ src/typings/objectAssign/objectAssign.d.ts | 15 --------------- src/utils.ts | 6 +++--- .../expectedOutput-2.1/output.txt | 4 ++-- 9 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 src/typings/objectAssign/objectAssign.d.ts diff --git a/.travis.yml b/.travis.yml index 8a7e5cb0b..a7ab3c5f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,9 @@ language: node_js node_js: - "4" + - "5" - "6" + - "7" sudo: false install: - npm install npm -g diff --git a/package.json b/package.json index 820945d82..09309bb6d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ "typescript", "ts" ], + "engines": { + "node" : ">=4.0" + }, "author": "James Brantly (http://www.jbrantly.com/)", "license": "MIT", "bugs": { @@ -31,7 +34,6 @@ "colors": "^1.0.3", "enhanced-resolve": "^3.0.0", "loader-utils": "^0.2.6", - "object-assign": "^4.1.0", "semver": "^5.0.1" }, "devDependencies": { diff --git a/src/compilerSetup.ts b/src/compilerSetup.ts index e623ad807..001a9dabd 100644 --- a/src/compilerSetup.ts +++ b/src/compilerSetup.ts @@ -1,5 +1,4 @@ import typescript = require('typescript'); -import objectAssign = require('object-assign'); const semver = require('semver'); import interfaces = require('./interfaces'); @@ -46,7 +45,7 @@ export function getCompilerOptions( compiler: typeof typescript, configParseResult: typescript.ParsedCommandLine ) { - const compilerOptions = objectAssign({}, configParseResult.options, { + const compilerOptions = Object.assign({}, configParseResult.options, { skipDefaultLibCheck: true, suppressOutputPathCheck: true, // This is why: https://github.com/Microsoft/TypeScript/issues/7363 }); diff --git a/src/config.ts b/src/config.ts index 90a6e37d7..8b7b5af4e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,3 @@ -import objectAssign = require('object-assign'); import typescript = require('typescript'); import path = require('path'); @@ -52,7 +51,7 @@ export function getConfigFile( } if (!configFileError) { - configFile.config.compilerOptions = objectAssign({}, + configFile.config.compilerOptions = Object.assign({}, configFile.config.compilerOptions, loaderOptions.compilerOptions); diff --git a/src/index.ts b/src/index.ts index 2a5b00c98..84861ca6c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ import path = require('path'); import loaderUtils = require('loader-utils'); -import objectAssign = require('object-assign'); require('colors'); import instances = require('./instances'); @@ -73,7 +72,7 @@ function getLoaderOptions(loader: interfaces.Webpack) { return loaderOptionsCache[instanceName]; } - const options = objectAssign({}, { + const options = Object.assign({}, { silent: false, logLevel: 'INFO', logInfoToStdOut: false, @@ -203,7 +202,7 @@ function makeSourceMap( return { output: outputText.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''), - sourceMap: objectAssign(JSON.parse(sourceMapText), { + sourceMap: Object.assign(JSON.parse(sourceMapText), { sources: [loaderUtils.getRemainingRequest(loader)], file: filePath, sourcesContent: [contents] diff --git a/src/tsconfig.json b/src/tsconfig.json index b9c70b543..4d3360115 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "target": "es5", "noImplicitAny": true, "noImplicitReturns": true, "noImplicitThis": false, @@ -7,6 +8,9 @@ "noUnusedParameters": true, "suppressImplicitAnyIndexErrors": true, "strictNullChecks": false, + "lib": [ + "dom", "es2015" + ], "module": "commonjs", "moduleResolution": "node", "outDir": "../dist" diff --git a/src/typings/objectAssign/objectAssign.d.ts b/src/typings/objectAssign/objectAssign.d.ts deleted file mode 100644 index 09ba96acd..000000000 --- a/src/typings/objectAssign/objectAssign.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Type definitions for object-assign 4.0.1 -// Project: https://github.com/sindresorhus/object-assign -// Definitions by: Christopher Brown -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module "object-assign" { - function objectAssign(target: T, source: U): T & U; - function objectAssign(target: T, source1: U, source2: V): T & U & V; - function objectAssign(target: T, source1: U, source2: V, source3: W): T & U & V & W; - function objectAssign(target: T, source1: U, source2: V, source3: W, source4: Q): T & U & V & W & Q; - function objectAssign(target: T, source1: U, source2: V, source3: W, source4: Q, source5: R): T & U & V & W & Q & R; - function objectAssign(target: any, ...sources: any[]): any; - namespace objectAssign { } - export = objectAssign; -} \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index e5b111468..6bcff68b7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,7 @@ import typescript = require('typescript'); import path = require('path'); import fs = require('fs'); -import objectAssign = require('object-assign'); + import constants = require('./constants'); import interfaces = require('./interfaces'); @@ -46,7 +46,7 @@ export function formatErrors( } else { error = makeError({ rawMessage: messageText }); } - return objectAssign(error, merge); + return Object.assign(error, merge); }); } @@ -73,7 +73,7 @@ export function makeError({ rawMessage, message, location, file }: MakeError): i loaderSource: 'ts-loader' }; - return objectAssign(error, { location, file }); + return Object.assign(error, { location, file }); } export function appendTsSuffixIfMatch(patterns: RegExp[], path: string): string { diff --git a/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.1/output.txt b/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.1/output.txt index e18a3c738..95ae1dbf8 100644 --- a/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.1/output.txt +++ b/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.1/output.txt @@ -5,9 +5,9 @@ chunk {0} bundle.js (main) 501 bytes [entry] [rendered] [1] ./.test/nodeModulesMeaningfulErrorWhenImportingTs/app.ts 52 bytes {0} [built] ERROR in ./.test/nodeModulesMeaningfulErrorWhenImportingTs/~/a/index.ts -Module build failed: Error: Typescript emitted no output for node_modules\a\index.ts. +Module build failed: Error: Typescript emitted no output for node_modules/a/index.ts. You should not need to recompile .ts files in node_modules. Please contact the package author to advise them to use --declaration --outDir. More https://github.com/Microsoft/TypeScript/issues/12358 - at Object.loader (dist\index.js:33:15) + at Object.loader (dist/index.js:32:15) @ ./.test/nodeModulesMeaningfulErrorWhenImportingTs/app.ts 2:8-20 \ No newline at end of file From a9ee8c15d9da5c7cb06fcba8d1597b8746b75ad2 Mon Sep 17 00:00:00 2001 From: arusakov Date: Mon, 19 Dec 2016 15:02:57 +0300 Subject: [PATCH 2/6] tsconfig comment about dom --- src/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tsconfig.json b/src/tsconfig.json index 4d3360115..b440a7add 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -9,7 +9,7 @@ "suppressImplicitAnyIndexErrors": true, "strictNullChecks": false, "lib": [ - "dom", "es2015" + "dom", "es2015" // dom for console.log only ], "module": "commonjs", "moduleResolution": "node", From 0f949e16b01b1145692709c5f904c70e11b08c17 Mon Sep 17 00:00:00 2001 From: arusakov Date: Mon, 19 Dec 2016 15:08:36 +0300 Subject: [PATCH 3/6] clear --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 09309bb6d..3b477db66 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "ts" ], "engines": { - "node" : ">=4.0" + "node": ">=4.0" }, "author": "James Brantly (http://www.jbrantly.com/)", "license": "MIT", From 4de90b1d20b8d912ed179548fc208a31c52e37a6 Mon Sep 17 00:00:00 2001 From: arusakov Date: Mon, 19 Dec 2016 15:26:51 +0300 Subject: [PATCH 4/6] fix nodeModulesMeaningfulErrorWhenImportingTs for TS2.0 --- .../expectedOutput-2.0/output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.0/output.txt b/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.0/output.txt index 2467f044a..11292e53f 100644 --- a/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.0/output.txt +++ b/test/comparison-tests/nodeModulesMeaningfulErrorWhenImportingTs/expectedOutput-2.0/output.txt @@ -4,9 +4,9 @@ chunk {0} bundle.js (main) 52 bytes [rendered] [0] ./.test/nodeModulesMeaningfulErrorWhenImportingTs/app.ts 52 bytes {0} [built] [1 error] ERROR in ./.test/nodeModulesMeaningfulErrorWhenImportingTs/~/a/index.ts -Module build failed: Error: Typescript emitted no output for node_modules\a\index.ts. +Module build failed: Error: Typescript emitted no output for node_modules/a/index.ts. You should not need to recompile .ts files in node_modules. Please contact the package author to advise them to use --declaration --outDir. More https://github.com/Microsoft/TypeScript/issues/12358 - at Object.loader (dist\index.js:33:15) + at Object.loader (dist/index.js:32:15) @ ./.test/nodeModulesMeaningfulErrorWhenImportingTs/app.ts 2:8-20 \ No newline at end of file From 7a9034de7c43acef51d6dfb8e975a4fd3f4ff493 Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Fri, 20 Jan 2017 13:32:06 +0300 Subject: [PATCH 5/6] definitions for console.log() --- src/tsconfig.json | 2 +- src/typings/console.log.d.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/typings/console.log.d.ts diff --git a/src/tsconfig.json b/src/tsconfig.json index b440a7add..cd717b073 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -9,7 +9,7 @@ "suppressImplicitAnyIndexErrors": true, "strictNullChecks": false, "lib": [ - "dom", "es2015" // dom for console.log only + "es5", "es2015.core" ], "module": "commonjs", "moduleResolution": "node", diff --git a/src/typings/console.log.d.ts b/src/typings/console.log.d.ts new file mode 100644 index 000000000..aa4491a6c --- /dev/null +++ b/src/typings/console.log.d.ts @@ -0,0 +1 @@ +declare const console: { log(...args: any[]): void }; From 390889630edd14c70d641f286e708f2afbb50bb4 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 20 Jan 2017 16:54:11 +0000 Subject: [PATCH 6/6] update package.json - match webpack 2's engines --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b477db66..a7346883b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "ts" ], "engines": { - "node": ">=4.0" + "node": ">=4.3.0 <5.0.0 || >=5.10" }, "author": "James Brantly (http://www.jbrantly.com/)", "license": "MIT",