Expected Behavior / Situation
When Rollup resolves file name conflicts, it adds a number to the conflicting file before the last dot of the file name. I.e. if it is creating a file named foo.bar.js but a file already exists with said name, then it names the new file foo.bar2.js.
This is fine in most scenarios (since in most cases a file only has a single dot), however, in others, a composition of multiple "extensions" in a file name is actually relevant meta-information for the type of file.
In particular, I'm using rollup-plugin-dts to generate type definitions for my library, which has multiple entry points. I have at some point in my Rollup configuration something like:
// ...
{
input: arrayOfEntryPoints,
output: [{ dir: "dist", chunkFileNames: "chunk.d.ts" }],
plugins: [dts()],
},
// ...
When generating chunks, I'd expect Rollup to emit files named: chunk.d.ts, chunk2.d.ts, chunk3.d.ts, ...
Actual Behavior / Situation
However, as previously mentioned, Rollup currently adds the number used to prevent file conflicts just before the last dot of the file, so chunk.d.ts, chunk.d2.ts, chunk.d3.ts, ... is generated instead.
This is problematic for this particular use-case since TypeScript type definitions are expected to have a file extension of .d.ts.
Modification Proposal
I propose that Rollup instead adds conflict-preventing numbers before the first dot of the file name, rather than the last, except when files start with a dot, in which case the number should be added before the second dot.
I believe that such behaviour is the least likely to cause problems related to file extensions. I can think of other scenarios where the current behaviour might cause problems (e.g. think of a plugin which generates tar.gz archives), whereas I can't think of any scenarios where this proposal would cause issues (other than breaking compatibility with the previous behaviour).
Expected Behavior / Situation
When Rollup resolves file name conflicts, it adds a number to the conflicting file before the last dot of the file name. I.e. if it is creating a file named
foo.bar.jsbut a file already exists with said name, then it names the new filefoo.bar2.js.This is fine in most scenarios (since in most cases a file only has a single dot), however, in others, a composition of multiple "extensions" in a file name is actually relevant meta-information for the type of file.
In particular, I'm using
rollup-plugin-dtsto generate type definitions for my library, which has multiple entry points. I have at some point in my Rollup configuration something like:When generating chunks, I'd expect Rollup to emit files named:
chunk.d.ts,chunk2.d.ts,chunk3.d.ts, ...Actual Behavior / Situation
However, as previously mentioned, Rollup currently adds the number used to prevent file conflicts just before the last dot of the file, so
chunk.d.ts,chunk.d2.ts,chunk.d3.ts, ... is generated instead.This is problematic for this particular use-case since TypeScript type definitions are expected to have a file extension of
.d.ts.Modification Proposal
I propose that Rollup instead adds conflict-preventing numbers before the first dot of the file name, rather than the last, except when files start with a dot, in which case the number should be added before the second dot.
I believe that such behaviour is the least likely to cause problems related to file extensions. I can think of other scenarios where the current behaviour might cause problems (e.g. think of a plugin which generates
tar.gzarchives), whereas I can't think of any scenarios where this proposal would cause issues (other than breaking compatibility with the previous behaviour).