Skip to content

Commit f4ee39c

Browse files
committed
- partial support for project references #139
1 parent 9188132 commit f4ee39c

6 files changed

+73
-84
lines changed

dist/get-options-overrides.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

dist/rollup-plugin-typescript2.cjs.js

+21-25
Original file line numberDiff line numberDiff line change
@@ -24975,35 +24975,31 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
2497524975
}
2497624976
return overrides;
2497724977
}
24978+
function expandIncludeWithDirs(include, dirs) {
24979+
return lodash_16(dirs)
24980+
.flatMap((root) => {
24981+
if (include instanceof Array)
24982+
return include.map((x) => path.join(root, x));
24983+
else
24984+
return path.join(root, include);
24985+
})
24986+
.uniq()
24987+
.value();
24988+
}
2497824989
function createFilter(context, pluginOptions, parsedConfig) {
24990+
let included = pluginOptions.include;
24991+
let excluded = pluginOptions.exclude;
2497924992
if (parsedConfig.options.rootDirs) {
24980-
const included = lodash_16(parsedConfig.options.rootDirs)
24981-
.flatMap((root) => {
24982-
if (pluginOptions.include instanceof Array)
24983-
return pluginOptions.include.map((include) => path.join(root, include));
24984-
else
24985-
return path.join(root, pluginOptions.include);
24986-
})
24987-
.uniq()
24988-
.value();
24989-
const excluded = lodash_16(parsedConfig.options.rootDirs)
24990-
.flatMap((root) => {
24991-
if (pluginOptions.exclude instanceof Array)
24992-
return pluginOptions.exclude.map((exclude) => path.join(root, exclude));
24993-
else
24994-
return path.join(root, pluginOptions.exclude);
24995-
})
24996-
.uniq()
24997-
.value();
24998-
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
24999-
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
25000-
return createRollupFilter(included, excluded);
24993+
included = expandIncludeWithDirs(included, parsedConfig.options.rootDirs);
24994+
excluded = expandIncludeWithDirs(excluded, parsedConfig.options.rootDirs);
2500124995
}
25002-
else {
25003-
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
25004-
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
25005-
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
24996+
if (parsedConfig.projectReferences) {
24997+
included = lodash_10(included, expandIncludeWithDirs(included, parsedConfig.projectReferences.map((x) => x.path)));
24998+
excluded = lodash_10(excluded, expandIncludeWithDirs(excluded, parsedConfig.projectReferences.map((x) => x.path)));
2500624999
}
25000+
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
25001+
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
25002+
return createRollupFilter(included, excluded);
2500725003
}
2500825004

2500925005
function checkTsConfig(parsedConfig) {

dist/rollup-plugin-typescript2.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollup-plugin-typescript2.es.js

+21-25
Original file line numberDiff line numberDiff line change
@@ -24971,35 +24971,31 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
2497124971
}
2497224972
return overrides;
2497324973
}
24974+
function expandIncludeWithDirs(include, dirs) {
24975+
return lodash_16(dirs)
24976+
.flatMap((root) => {
24977+
if (include instanceof Array)
24978+
return include.map((x) => join(root, x));
24979+
else
24980+
return join(root, include);
24981+
})
24982+
.uniq()
24983+
.value();
24984+
}
2497424985
function createFilter(context, pluginOptions, parsedConfig) {
24986+
let included = pluginOptions.include;
24987+
let excluded = pluginOptions.exclude;
2497524988
if (parsedConfig.options.rootDirs) {
24976-
const included = lodash_16(parsedConfig.options.rootDirs)
24977-
.flatMap((root) => {
24978-
if (pluginOptions.include instanceof Array)
24979-
return pluginOptions.include.map((include) => join(root, include));
24980-
else
24981-
return join(root, pluginOptions.include);
24982-
})
24983-
.uniq()
24984-
.value();
24985-
const excluded = lodash_16(parsedConfig.options.rootDirs)
24986-
.flatMap((root) => {
24987-
if (pluginOptions.exclude instanceof Array)
24988-
return pluginOptions.exclude.map((exclude) => join(root, exclude));
24989-
else
24990-
return join(root, pluginOptions.exclude);
24991-
})
24992-
.uniq()
24993-
.value();
24994-
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
24995-
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
24996-
return createRollupFilter(included, excluded);
24989+
included = expandIncludeWithDirs(included, parsedConfig.options.rootDirs);
24990+
excluded = expandIncludeWithDirs(excluded, parsedConfig.options.rootDirs);
2499724991
}
24998-
else {
24999-
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
25000-
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
25001-
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
24992+
if (parsedConfig.projectReferences) {
24993+
included = lodash_10(included, expandIncludeWithDirs(included, parsedConfig.projectReferences.map((x) => x.path)));
24994+
excluded = lodash_10(excluded, expandIncludeWithDirs(excluded, parsedConfig.projectReferences.map((x) => x.path)));
2500224995
}
24996+
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
24997+
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
24998+
return createRollupFilter(included, excluded);
2500324999
}
2500425000

2500525001
function checkTsConfig(parsedConfig) {

dist/rollup-plugin-typescript2.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/get-options-overrides.ts

+28-31
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,39 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
4141
return overrides;
4242
}
4343

44+
function expandIncludeWithDirs(include: string | string[], dirs: string[])
45+
{
46+
return _
47+
.chain(dirs)
48+
.flatMap((root) =>
49+
{
50+
if (include instanceof Array)
51+
return include.map((x) => join(root, x));
52+
else
53+
return join(root, include);
54+
})
55+
.uniq()
56+
.value();
57+
}
58+
4459
export function createFilter(context: IContext, pluginOptions: IOptions, parsedConfig: tsTypes.ParsedCommandLine)
4560
{
61+
let included = pluginOptions.include;
62+
let excluded = pluginOptions.exclude;
63+
4664
if (parsedConfig.options.rootDirs)
4765
{
48-
const included = _
49-
.chain(parsedConfig.options.rootDirs)
50-
.flatMap((root) =>
51-
{
52-
if (pluginOptions.include instanceof Array)
53-
return pluginOptions.include.map((include) => join(root, include));
54-
else
55-
return join(root, pluginOptions.include);
56-
})
57-
.uniq()
58-
.value();
59-
60-
const excluded = _
61-
.chain(parsedConfig.options.rootDirs)
62-
.flatMap((root) =>
63-
{
64-
if (pluginOptions.exclude instanceof Array)
65-
return pluginOptions.exclude.map((exclude) => join(root, exclude));
66-
else
67-
return join(root, pluginOptions.exclude);
68-
})
69-
.uniq()
70-
.value();
71-
72-
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
73-
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
74-
return createRollupFilter(included, excluded);
66+
included = expandIncludeWithDirs(included, parsedConfig.options.rootDirs);
67+
excluded = expandIncludeWithDirs(excluded, parsedConfig.options.rootDirs);
7568
}
76-
else
69+
70+
if (parsedConfig.projectReferences)
7771
{
78-
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
79-
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
80-
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
72+
included = _.concat(included, expandIncludeWithDirs(included, parsedConfig.projectReferences.map((x) => x.path)));
73+
excluded = _.concat(excluded, expandIncludeWithDirs(excluded, parsedConfig.projectReferences.map((x) => x.path)));
8174
}
75+
76+
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
77+
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
78+
return createRollupFilter(included, excluded);
8279
}

0 commit comments

Comments
 (0)