Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.4.13

* [Merge in `compilerOptions` prior to calling `parseJsonConfigFileContent`](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/176) (#176)

## v0.4.12

* [Add `compilerOptions` option](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/173) (#173)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fork-ts-checker-webpack-plugin",
"version": "0.4.12",
"version": "0.4.13",
"description": "Runs typescript type checker and linter on separate process.",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
Expand Down
15 changes: 9 additions & 6 deletions src/IncrementalChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,20 @@ export class IncrementalChecker {
}

static loadProgramConfig(configFile: string, compilerOptions: object) {
const tsconfig = ts.readConfigFile(configFile, ts.sys.readFile).config;

tsconfig.compilerOptions = tsconfig.compilerOptions || {};
tsconfig.compilerOptions = {
...tsconfig.compilerOptions,
...compilerOptions
};

const parsed = ts.parseJsonConfigFileContent(
// Regardless of the setting in the tsconfig.json we want isolatedModules to be false
Object.assign(ts.readConfigFile(configFile, ts.sys.readFile).config, {
isolatedModules: false
}),
tsconfig,
ts.sys,
path.dirname(configFile)
);

parsed.options = { ...parsed.options, ...compilerOptions };

return parsed;
}

Expand Down
14 changes: 9 additions & 5 deletions src/VueProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ export class VueProgram {
}
};

const tsconfig = ts.readConfigFile(configFile, ts.sys.readFile).config;

tsconfig.compilerOptions = tsconfig.compilerOptions || {};
tsconfig.compilerOptions = {
...tsconfig.compilerOptions,
...compilerOptions
};

const parsed = ts.parseJsonConfigFileContent(
// Regardless of the setting in the tsconfig.json we want isolatedModules to be false
Object.assign(ts.readConfigFile(configFile, ts.sys.readFile).config, {
isolatedModules: false
}),
tsconfig,
parseConfigHost,
path.dirname(configFile)
);

parsed.options.allowNonTsExtensions = true;
parsed.options = { ...parsed.options, ...compilerOptions };

return parsed;
}
Expand Down
37 changes: 24 additions & 13 deletions test/unit/IncrementalChecker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@ var sinon = require('sinon');

describe('[UNIT] IncrementalChecker', function() {
var IncrementalChecker;
var parseJsonConfigFileContentStub;

beforeEach(function() {
var parseJsonConfigFileContentStub = sinon.stub().returns({
options: {
foo: true
}
});
var readConfigFileStub = sinon.stub().returns({
config: {}
parseJsonConfigFileContentStub = sinon.spy(function(tsconfig) {
return {
options: tsconfig.compilerOptions
};
});

var readConfigFile = function() {
return {
config: {
compilerOptions: {
foo: true
}
}
};
};

mockRequire('typescript', {
parseJsonConfigFileContent: parseJsonConfigFileContentStub,
readConfigFile: readConfigFileStub,
readConfigFile,
sys: {}
});

Expand Down Expand Up @@ -68,14 +76,17 @@ describe('[UNIT] IncrementalChecker', function() {
});

describe('loadProgramConfig', function() {
it('merges compilerOptions into returned options', function() {
var result = IncrementalChecker.loadProgramConfig('tsconfig.foo.json', {
it('merges compilerOptions into config file options', function() {
IncrementalChecker.loadProgramConfig('tsconfig.foo.json', {
bar: false
});

expect(result.options).to.deep.equal({
foo: true,
bar: false
expect(parseJsonConfigFileContentStub.calledOnce).to.equal(true);
expect(parseJsonConfigFileContentStub.args[0][0]).to.deep.equal({
compilerOptions: {
foo: true,
bar: false
}
});
});
});
Expand Down
39 changes: 25 additions & 14 deletions test/unit/VueProgram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@ var sinon = require('sinon');

describe('[UNIT] VueProgram', function() {
var VueProgram;
var parseJsonConfigFileContentStub;

beforeEach(function() {
var parseJsonConfigFileContentStub = sinon.stub().returns({
options: {
foo: true
}
});
var readConfigFileStub = sinon.stub().returns({
config: {}
parseJsonConfigFileContentStub = sinon.spy(function(tsconfig) {
return {
options: tsconfig.compilerOptions
};
});

var readConfigFile = function() {
return {
config: {
compilerOptions: {
foo: true
}
}
};
};

mockRequire('typescript', {
parseJsonConfigFileContent: parseJsonConfigFileContentStub,
readConfigFile: readConfigFileStub,
readConfigFile,
sys: {},
ScriptKind: ts.ScriptKind
});
Expand Down Expand Up @@ -165,15 +173,18 @@ describe('[UNIT] VueProgram', function() {
expect(result.options.allowNonTsExtensions).to.equal(true);
});

it('merges compilerOptions into returned options', function() {
var result = VueProgram.loadProgramConfig('tsconfig.foo.json', {
it('merges compilerOptions into config file options', function() {
VueProgram.loadProgramConfig('tsconfig.foo.json', {
bar: false
});

expect(result.options).to.deep.equal({
foo: true,
bar: false,
allowNonTsExtensions: true
expect(parseJsonConfigFileContentStub.calledOnce).to.equal(true);
expect(parseJsonConfigFileContentStub.args[0][0]).to.deep.equal({
compilerOptions: {
allowNonTsExtensions: true,
foo: true,
bar: false
}
});
});
});
Expand Down