Skip to content

Commit 4806613

Browse files
committed
Merge branch 'cuyl-fix-missing-file'
2 parents 29b13a0 + 578536a commit 4806613

6 files changed

+15
-12
lines changed

dist/index.d.ts.map

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

dist/rollup-plugin-typescript2.cjs.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -26625,7 +26625,7 @@ const typescript = (options) => {
2662526625
cache().done();
2662626626
generateRound++;
2662726627
},
26628-
_onwrite({ file }) {
26628+
_onwrite({ file, dir }) {
2662926629
if (parsedConfig.options.declaration) {
2663026630
lodash_2(parsedConfig.fileNames, (name) => {
2663126631
const key = normalize(name);
@@ -26638,6 +26638,7 @@ const typescript = (options) => {
2663826638
declarations[key] = { type: out.dts, map: out.dtsmap };
2663926639
});
2664026640
const bundleFile = file;
26641+
const outputDir = dir;
2664126642
const writeDeclaration = (key, extension, entry) => {
2664226643
if (!entry)
2664326644
return;
@@ -26647,11 +26648,11 @@ const typescript = (options) => {
2664726648
let writeToPath;
2664826649
// If for some reason no 'dest' property exists or if 'useTsconfigDeclarationDir' is given in the plugin options,
2664926650
// use the path provided by Typescript's LanguageService.
26650-
if (!bundleFile || pluginOptions.useTsconfigDeclarationDir)
26651+
if ((!bundleFile && !outputDir) || pluginOptions.useTsconfigDeclarationDir)
2665126652
writeToPath = fileName;
2665226653
else {
2665326654
// Otherwise, take the directory name from the path and make sure it is absolute.
26654-
const destDirname = path.dirname(bundleFile);
26655+
const destDirname = bundleFile ? path.dirname(bundleFile) : outputDir;
2665526656
const destDirectory = path.isAbsolute(destDirname) ? destDirname : path.join(process.cwd(), destDirname);
2665626657
writeToPath = path.join(destDirectory, path.relative(process.cwd(), fileName));
2665726658
}

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -26621,7 +26621,7 @@ const typescript = (options) => {
2662126621
cache().done();
2662226622
generateRound++;
2662326623
},
26624-
_onwrite({ file }) {
26624+
_onwrite({ file, dir }) {
2662526625
if (parsedConfig.options.declaration) {
2662626626
lodash_2(parsedConfig.fileNames, (name) => {
2662726627
const key = normalize(name);
@@ -26634,6 +26634,7 @@ const typescript = (options) => {
2663426634
declarations[key] = { type: out.dts, map: out.dtsmap };
2663526635
});
2663626636
const bundleFile = file;
26637+
const outputDir = dir;
2663726638
const writeDeclaration = (key, extension, entry) => {
2663826639
if (!entry)
2663926640
return;
@@ -26643,11 +26644,11 @@ const typescript = (options) => {
2664326644
let writeToPath;
2664426645
// If for some reason no 'dest' property exists or if 'useTsconfigDeclarationDir' is given in the plugin options,
2664526646
// use the path provided by Typescript's LanguageService.
26646-
if (!bundleFile || pluginOptions.useTsconfigDeclarationDir)
26647+
if ((!bundleFile && !outputDir) || pluginOptions.useTsconfigDeclarationDir)
2664726648
writeToPath = fileName;
2664826649
else {
2664926650
// Otherwise, take the directory name from the path and make sure it is absolute.
26650-
const destDirname = dirname(bundleFile);
26651+
const destDirname = bundleFile ? dirname(bundleFile) : outputDir;
2665126652
const destDirectory = isAbsolute(destDirname) ? destDirname : join(process.cwd(), destDirname);
2665226653
writeToPath = join(destDirectory, relative(process.cwd(), fileName));
2665326654
}

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/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
283283
generateRound++;
284284
},
285285

286-
_onwrite({ file }: OutputOptions): void
286+
_onwrite({ file, dir }: OutputOptions): void
287287
{
288288
if (parsedConfig.options.declaration)
289289
{
@@ -300,6 +300,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
300300
});
301301

302302
const bundleFile = file;
303+
const outputDir = dir;
303304

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

0 commit comments

Comments
 (0)