File tree 2 files changed +37
-4
lines changed
2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,16 @@ export function validatePaths(
58
58
for ( const dirProperty of DIRECTORY_PROPS ) {
59
59
if ( compilerOptions [ dirProperty ] && outputDir ) {
60
60
// Checks if the given path lies within Rollup output dir
61
- const fromRollupDirToTs = relative ( outputDir , compilerOptions [ dirProperty ] ! ) ;
62
- if ( fromRollupDirToTs . startsWith ( '..' ) ) {
63
- if ( outputOptions . dir ) {
61
+ if ( outputOptions . dir ) {
62
+ const fromRollupDirToTs = relative ( outputDir , compilerOptions [ dirProperty ] ! ) ;
63
+ if ( fromRollupDirToTs . startsWith ( '..' ) ) {
64
64
context . error (
65
65
`@rollup/plugin-typescript: Path of Typescript compiler option '${ dirProperty } ' must be located inside Rollup 'dir' option.`
66
66
) ;
67
- } else {
67
+ }
68
+ } else {
69
+ const fromTsDirToRollup = relative ( compilerOptions [ dirProperty ] ! , outputDir ) ;
70
+ if ( fromTsDirToRollup . startsWith ( '..' ) ) {
68
71
context . error (
69
72
`@rollup/plugin-typescript: Path of Typescript compiler option '${ dirProperty } ' must be located inside the same directory as the Rollup 'file' option.`
70
73
) ;
Original file line number Diff line number Diff line change @@ -129,6 +129,36 @@ test.serial(
129
129
}
130
130
) ;
131
131
132
+ test . serial (
133
+ 'ensures output files can be written to subdirectories within the tsconfig outDir' ,
134
+ async ( t ) => {
135
+ const warnings = [ ] ;
136
+ const outputOpts = { format : 'es' , file : 'fixtures/basic/dist/esm/main.js' } ;
137
+ const bundle = await rollup ( {
138
+ input : 'fixtures/basic/main.ts' ,
139
+ output : outputOpts ,
140
+ plugins : [
141
+ typescript ( {
142
+ tsconfig : 'fixtures/basic/tsconfig.json' ,
143
+ outDir : 'fixtures/basic/dist'
144
+ } )
145
+ ] ,
146
+ onwarn ( warning ) {
147
+ warnings . push ( warning ) ;
148
+ }
149
+ } ) ;
150
+
151
+ // This should not throw an error
152
+ const output = await getFiles ( bundle , outputOpts ) ;
153
+
154
+ t . deepEqual (
155
+ output . map ( ( out ) => out . fileName ) ,
156
+ [ 'fixtures/basic/dist/esm/main.js' ]
157
+ ) ;
158
+ t . is ( warnings . length , 0 ) ;
159
+ }
160
+ ) ;
161
+
132
162
test . serial ( 'ensures multiple outputs can be built' , async ( t ) => {
133
163
// In a rollup.config.js we would pass an array
134
164
// The rollup method that's exported as a library won't do that so we must make two calls
You can’t perform that action at this time.
0 commit comments