Skip to content

[rollup-plugin-typescript] declarationDir inside same directory as file option #1773

Closed

Description

@mririgoyen

Perhaps related to #1772.

  • Rollup Plugin Name: rollup-plugin-typescript
  • Rollup Plugin Version: 12.1.0
  • Rollup Version: 4.22.4
  • Operating System (or Browser):
  • Node Version: 20.17

Expected Behavior

Nested sub-directories continue to be valid.

Actual Behavior

Based on the breaking change, output must be the same as the declaration directory. However, I believe this check is being over-zealous, disallowing sub-directories within the declaration directory.

After the v12 update, the following error is presented:

@rollup/plugin-typescript: Path of Typescript compiler option 'declarationDir' must be located inside the same directory as the Rollup 'file' option.

Additional Information

The declaration directory in tsconfig.json:

"declarationDir": "lib",

The rollup config:

  {
    input: 'src/tailwind/config.ts',
    output: [{ file: 'lib/tailwind/config.js', format: 'cjs' }],
    plugins: [
      typescript({
        filterRoot: 'src/tailwind',
      }),
    ],
  },

If I simplify the output to lib/config.js, the error is gone. However, my directory structure is no longer valid.

Activity

  1. shellscape commented on Sep 24, 2024

    @shellscape
    Collaborator

    We'd be happy to take a look at a Pull Request which resolves this condition, but one which keeps current tests passing.

    (Please also note that moving forward, issues without a valid reproduction will be moved to a Q & A discussion. Those aren't optional, and the issue template mentions that a bunch)

  2. michaelfaith commented on Oct 9, 2024

    @michaelfaith
    Contributor

    I'm not sure i fully understand the motivation for the change that caused this; the pr didn't really go into much detail as to why this was needed. But, if i understand the code changed, it could be that reversing the order of these params making the path from ts to rollup, rather than rollup to ts, could be enough to fix the case of nested directories within the outDir and still satisfy the new unit tests.

    const fromRollupDirToTs = relative(outputDir, compilerOptions[dirProperty]!);

  3. kahagerman commented on Oct 21, 2024

    @kahagerman

    This is also a regression for .d.ts files when we need to write them somewhere else first.

    We use api-extractor, so we want to write out the *.d.ts to a different directory (currently ./lib/types) so they can be post-processed there.

    This is broken with versions >=12.1.0.

  4. shellscape commented on Oct 21, 2024

    @shellscape
    Collaborator

    @kahagerman breaking changes on major versions are not regressions.

    this PR will likely not get further discussion on this page. there are active issues and PRs open, please take discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions