Skip to content

Commit

Permalink
- if output.file not exist use output.dir
Browse files Browse the repository at this point in the history
  • Loading branch information
cuyl committed Mar 8, 2019
1 parent f4ee39c commit b00ae06
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
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

0 comments on commit b00ae06

Please sign in to comment.