Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript): allow for files to be nested in folders within outDir #1783

Merged

Conversation

michaelfaith
Copy link
Contributor

Rollup Plugin Name: typescript

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

Description

This change corrects a regression introduced by #1728, preventing dual bundle configs from writing output files to directories nested within the directory defined in the tsconfig's outDir property.

Example:

export default {
  input: 'src/index.ts', 
  output: [
    {
      file: 'dist/cjs/index.cjs',
      format: 'cjs',
    },
    {
      file: 'dist/esm/index.mjs',
      format: 'esm',
    }
  ],
  plugins: [
    typescript({
      tsconfig: 'tsconfig.json',
      compilerOptions: {
        outDir: 'dist'
      }
    })
  ],
};

Fixes #1773

This change corrects a regression introduced by rollup#1728, preventing dual bundle configs from writing output files to directories nested within the directory defined in the tsconfig's outDir property.

Example:
```js
export default {
  input: 'src/index.ts', // Replace with the path to your entry TypeScript file
  output: [
    {
      dir: 'dist/cjs',
      format: 'cjs',
      sourcemap: true,
      preserveModules: true
    },
    {
      dir: 'dist/esm',
      format: 'esm',
      sourcemap: true,
      preserveModules: true
    }
  ],
  plugins: [
    json(),
    resolve(),
    commonjs(),
    typescript({
      tsconfig: 'tsconfig.json',
      compilerOptions: {
        /* Basic Options */
        target: 'ES5',
        module: 'ES2020',
        lib: ['ES2019', 'ES2020'],
        allowJs: true,
        checkJs: false,
        /* Strict Type-Checking Options */
        strict: true,
        /* Module Resolution Options */
        moduleResolution: 'node',
        esModuleInterop: true,
        /* Advanced Options */
        forceConsistentCasingInFileNames: true,
        skipDefaultLibCheck: true,
        skipLibCheck: true,
        outDir: path.join(__dirname, 'dist')
      }
    })
  ],
  external: deps // Add any external dependencies you don't want to bundle
};
```
@michaelfaith michaelfaith marked this pull request as ready for review October 10, 2024 13:23
@shellscape
Copy link
Collaborator

Appreciate you stepping up on this one.

thanks!

@shellscape shellscape merged commit cc55c44 into rollup:master Oct 16, 2024
5 checks passed
remarkablemark added a commit to remarkablemark/npm-package-typescript-template that referenced this pull request Nov 10, 2024
mergify bot pushed a commit to remarkablemark/npm-package-typescript-template that referenced this pull request Nov 10, 2024
…#641)

* build(deps-dev): bump @rollup/plugin-typescript from 11.1.6 to 12.1.1

Bumps [@rollup/plugin-typescript](https://github.com/rollup/plugins/tree/HEAD/packages/typescript) from 11.1.6 to 12.1.1.
- [Changelog](https://github.com/rollup/plugins/blob/master/packages/typescript/CHANGELOG.md)
- [Commits](https://github.com/rollup/plugins/commits/typescript-v12.1.1/packages/typescript)

---
updated-dependencies:
- dependency-name: "@rollup/plugin-typescript"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(rollup): allow for files to be nested in folders within outDir

See rollup/plugins#1783

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mark <mark@remarkablemark.org>
remarkablemark added a commit to remarkablemark/html-react-parser that referenced this pull request Nov 10, 2024
See rollup/plugins#1783

```
 @rollup/plugin-typescript  11.1.6  →  12.1.1
 rollup                     4.24.4  →  4.25.0
```
remarkablemark added a commit to remarkablemark/html-react-parser that referenced this pull request Nov 10, 2024
See rollup/plugins#1783

```
 @rollup/plugin-typescript  11.1.6  →  12.1.1
 rollup                     4.24.4  →  4.25.0
```
remarkablemark added a commit to remarkablemark/html-react-parser that referenced this pull request Nov 10, 2024
See rollup/plugins#1783

```
 @rollup/plugin-typescript  11.1.6  →  12.1.1
 rollup                     4.24.4  →  4.25.0
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[rollup-plugin-typescript] declarationDir inside same directory as file option
2 participants