Skip to content

if fileproperty not exists fallback to dir. #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2019
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
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

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

7 changes: 4 additions & 3 deletions dist/rollup-plugin-typescript2.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26625,7 +26625,7 @@ const typescript = (options) => {
cache().done();
generateRound++;
},
_onwrite({ file }) {
_onwrite({ file, dir }) {
if (parsedConfig.options.declaration) {
lodash_2(parsedConfig.fileNames, (name) => {
const key = normalize(name);
Expand All @@ -26638,6 +26638,7 @@ const typescript = (options) => {
declarations[key] = { type: out.dts, map: out.dtsmap };
});
const bundleFile = file;
const outputDir = dir;
const writeDeclaration = (key, extension, entry) => {
if (!entry)
return;
Expand All @@ -26647,11 +26648,11 @@ const typescript = (options) => {
let writeToPath;
// If for some reason no 'dest' property exists or if 'useTsconfigDeclarationDir' is given in the plugin options,
// use the path provided by Typescript's LanguageService.
if (!bundleFile || pluginOptions.useTsconfigDeclarationDir)
if ((!bundleFile && !outputDir) || pluginOptions.useTsconfigDeclarationDir)
writeToPath = fileName;
else {
// Otherwise, take the directory name from the path and make sure it is absolute.
const destDirname = path.dirname(bundleFile);
const destDirname = bundleFile ? path.dirname(bundleFile) : outputDir;
const destDirectory = path.isAbsolute(destDirname) ? destDirname : path.join(process.cwd(), destDirname);
writeToPath = path.join(destDirectory, path.relative(process.cwd(), fileName));
}
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.cjs.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions dist/rollup-plugin-typescript2.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -26621,7 +26621,7 @@ const typescript = (options) => {
cache().done();
generateRound++;
},
_onwrite({ file }) {
_onwrite({ file, dir }) {
if (parsedConfig.options.declaration) {
lodash_2(parsedConfig.fileNames, (name) => {
const key = normalize(name);
Expand All @@ -26634,6 +26634,7 @@ const typescript = (options) => {
declarations[key] = { type: out.dts, map: out.dtsmap };
});
const bundleFile = file;
const outputDir = dir;
const writeDeclaration = (key, extension, entry) => {
if (!entry)
return;
Expand All @@ -26643,11 +26644,11 @@ const typescript = (options) => {
let writeToPath;
// If for some reason no 'dest' property exists or if 'useTsconfigDeclarationDir' is given in the plugin options,
// use the path provided by Typescript's LanguageService.
if (!bundleFile || pluginOptions.useTsconfigDeclarationDir)
if ((!bundleFile && !outputDir) || pluginOptions.useTsconfigDeclarationDir)
writeToPath = fileName;
else {
// Otherwise, take the directory name from the path and make sure it is absolute.
const destDirname = dirname(bundleFile);
const destDirname = bundleFile ? dirname(bundleFile) : outputDir;
const destDirectory = isAbsolute(destDirname) ? destDirname : join(process.cwd(), destDirname);
writeToPath = join(destDirectory, relative(process.cwd(), fileName));
}
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.es.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
generateRound++;
},

_onwrite({ file }: OutputOptions): void
_onwrite({ file, dir }: OutputOptions): void
{
if (parsedConfig.options.declaration)
{
Expand All @@ -300,6 +300,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
});

const bundleFile = file;
const outputDir = dir;

const writeDeclaration = (key: string, extension: string, entry?: tsTypes.OutputFile) =>
{
Expand All @@ -313,12 +314,12 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
let writeToPath: string;
// If for some reason no 'dest' property exists or if 'useTsconfigDeclarationDir' is given in the plugin options,
// use the path provided by Typescript's LanguageService.
if (!bundleFile || pluginOptions.useTsconfigDeclarationDir)
if ((!bundleFile && !outputDir) || pluginOptions.useTsconfigDeclarationDir)
writeToPath = fileName;
else
{
// Otherwise, take the directory name from the path and make sure it is absolute.
const destDirname = dirname(bundleFile);
const destDirname = bundleFile ? dirname(bundleFile) : <string>outputDir;
const destDirectory = isAbsolute(destDirname) ? destDirname : join(process.cwd(), destDirname);
writeToPath = join(destDirectory, relative(process.cwd(), fileName));
}
Expand Down