Skip to content

Commit

Permalink
- partial support for project references #139
Browse files Browse the repository at this point in the history
  • Loading branch information
ezolenko committed Feb 25, 2019
1 parent 9188132 commit f4ee39c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 84 deletions.
2 changes: 1 addition & 1 deletion dist/get-options-overrides.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 21 additions & 25 deletions dist/rollup-plugin-typescript2.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24975,35 +24975,31 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
}
return overrides;
}
function expandIncludeWithDirs(include, dirs) {
return lodash_16(dirs)
.flatMap((root) => {
if (include instanceof Array)
return include.map((x) => path.join(root, x));
else
return path.join(root, include);
})
.uniq()
.value();
}
function createFilter(context, pluginOptions, parsedConfig) {
let included = pluginOptions.include;
let excluded = pluginOptions.exclude;
if (parsedConfig.options.rootDirs) {
const included = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => path.join(root, include));
else
return path.join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => path.join(root, exclude));
else
return path.join(root, pluginOptions.exclude);
})
.uniq()
.value();
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
included = expandIncludeWithDirs(included, parsedConfig.options.rootDirs);
excluded = expandIncludeWithDirs(excluded, parsedConfig.options.rootDirs);
}
else {
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
if (parsedConfig.projectReferences) {
included = lodash_10(included, expandIncludeWithDirs(included, parsedConfig.projectReferences.map((x) => x.path)));
excluded = lodash_10(excluded, expandIncludeWithDirs(excluded, parsedConfig.projectReferences.map((x) => x.path)));
}
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
}

function checkTsConfig(parsedConfig) {
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.cjs.js.map

Large diffs are not rendered by default.

46 changes: 21 additions & 25 deletions dist/rollup-plugin-typescript2.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -24971,35 +24971,31 @@ function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }, preParsed
}
return overrides;
}
function expandIncludeWithDirs(include, dirs) {
return lodash_16(dirs)
.flatMap((root) => {
if (include instanceof Array)
return include.map((x) => join(root, x));
else
return join(root, include);
})
.uniq()
.value();
}
function createFilter(context, pluginOptions, parsedConfig) {
let included = pluginOptions.include;
let excluded = pluginOptions.exclude;
if (parsedConfig.options.rootDirs) {
const included = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => join(root, include));
else
return join(root, pluginOptions.include);
})
.uniq()
.value();
const excluded = lodash_16(parsedConfig.options.rootDirs)
.flatMap((root) => {
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => join(root, exclude));
else
return join(root, pluginOptions.exclude);
})
.uniq()
.value();
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
included = expandIncludeWithDirs(included, parsedConfig.options.rootDirs);
excluded = expandIncludeWithDirs(excluded, parsedConfig.options.rootDirs);
}
else {
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
if (parsedConfig.projectReferences) {
included = lodash_10(included, expandIncludeWithDirs(included, parsedConfig.projectReferences.map((x) => x.path)));
excluded = lodash_10(excluded, expandIncludeWithDirs(excluded, parsedConfig.projectReferences.map((x) => x.path)));
}
context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
}

function checkTsConfig(parsedConfig) {
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.es.js.map

Large diffs are not rendered by default.

59 changes: 28 additions & 31 deletions src/get-options-overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,39 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
return overrides;
}

function expandIncludeWithDirs(include: string | string[], dirs: string[])
{
return _
.chain(dirs)
.flatMap((root) =>
{
if (include instanceof Array)
return include.map((x) => join(root, x));
else
return join(root, include);
})
.uniq()
.value();
}

export function createFilter(context: IContext, pluginOptions: IOptions, parsedConfig: tsTypes.ParsedCommandLine)
{
let included = pluginOptions.include;
let excluded = pluginOptions.exclude;

if (parsedConfig.options.rootDirs)
{
const included = _
.chain(parsedConfig.options.rootDirs)
.flatMap((root) =>
{
if (pluginOptions.include instanceof Array)
return pluginOptions.include.map((include) => join(root, include));
else
return join(root, pluginOptions.include);
})
.uniq()
.value();

const excluded = _
.chain(parsedConfig.options.rootDirs)
.flatMap((root) =>
{
if (pluginOptions.exclude instanceof Array)
return pluginOptions.exclude.map((exclude) => join(root, exclude));
else
return join(root, pluginOptions.exclude);
})
.uniq()
.value();

context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
included = expandIncludeWithDirs(included, parsedConfig.options.rootDirs);
excluded = expandIncludeWithDirs(excluded, parsedConfig.options.rootDirs);
}
else

if (parsedConfig.projectReferences)
{
context.debug(() => `included:\n'${JSON.stringify(pluginOptions.include, undefined, 4)}'`);
context.debug(() => `excluded:\n'${JSON.stringify(pluginOptions.exclude, undefined, 4)}'`);
return createRollupFilter(pluginOptions.include, pluginOptions.exclude);
included = _.concat(included, expandIncludeWithDirs(included, parsedConfig.projectReferences.map((x) => x.path)));
excluded = _.concat(excluded, expandIncludeWithDirs(excluded, parsedConfig.projectReferences.map((x) => x.path)));
}

context.debug(() => `included:\n${JSON.stringify(included, undefined, 4)}`);
context.debug(() => `excluded:\n${JSON.stringify(excluded, undefined, 4)}`);
return createRollupFilter(included, excluded);
}

0 comments on commit f4ee39c

Please sign in to comment.