Skip to content

Commit

Permalink
Use native Object.assign() (#418)
Browse files Browse the repository at this point in the history
* Use native Object.assign()

* tsconfig comment about dom

* clear

* fix nodeModulesMeaningfulErrorWhenImportingTs for TS2.0

* definitions for console.log()

* update package.json - match webpack 2's engines
  • Loading branch information
arusakov authored and johnnyreilly committed Jan 21, 2017
1 parent adcc15e commit f4d8e71
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: node_js
node_js:
- "4"
- "5"
- "6"
- "7"
sudo: false
install:
- npm install npm -g
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"typescript",
"ts"
],
"engines": {
"node": ">=4.3.0 <5.0.0 || >=5.10"
},
"author": "James Brantly <james@jbrantly.com> (http://www.jbrantly.com/)",
"license": "MIT",
"bugs": {
Expand All @@ -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": {
Expand Down
3 changes: 1 addition & 2 deletions src/compilerSetup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import typescript = require('typescript');
import objectAssign = require('object-assign');
const semver = require('semver');

import interfaces = require('./interfaces');
Expand Down Expand Up @@ -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
});
Expand Down
3 changes: 1 addition & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import objectAssign = require('object-assign');
import typescript = require('typescript');
import path = require('path');

Expand Down Expand Up @@ -52,7 +51,7 @@ export function getConfigFile(
}

if (!configFileError) {
configFile.config.compilerOptions = objectAssign({},
configFile.config.compilerOptions = Object.assign({},
configFile.config.compilerOptions,
loaderOptions.compilerOptions);

Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path = require('path');
import loaderUtils = require('loader-utils');
import objectAssign = require('object-assign');
require('colors');

import instances = require('./instances');
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": false,
"lib": [
"es5", "es2015.core"
],
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../dist"
Expand Down
1 change: 1 addition & 0 deletions src/typings/console.log.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const console: { log(...args: any[]): void };
15 changes: 0 additions & 15 deletions src/typings/objectAssign/objectAssign.d.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -46,7 +46,7 @@ export function formatErrors(
} else {
error = makeError({ rawMessage: messageText });
}
return <interfaces.WebpackError>objectAssign(error, merge);
return <interfaces.WebpackError>Object.assign(error, merge);
});
}

Expand All @@ -73,7 +73,7 @@ export function makeError({ rawMessage, message, location, file }: MakeError): i
loaderSource: 'ts-loader'
};

return <interfaces.WebpackError>objectAssign(error, { location, file });
return <interfaces.WebpackError>Object.assign(error, { location, file });
}

export function appendTsSuffixIfMatch(patterns: RegExp[], path: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f4d8e71

Please sign in to comment.