Skip to content

[Bug]: extension of js request is not correct when using autoExtension: false along with output.filename.js #362

@xc2

Description

@xc2

Version


  System:
    OS: macOS 15.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 79.05 MB / 32.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Browsers:
    Chrome: 130.0.6723.92
    Safari: 18.1
  npmPackages:
    @rslib/core: ^0.0.15 => 0.0.15

Details

Cannot even set output.filename.js when autoExtension is false

Setup

package.json of workspace

{ "type": "module" }

rslib.config.ts

// ...
  format: 'esm',
  autoExtension: false,
  output: {
    filename: {
      js: '[name].mjs'
    }
  }
// ...
  format: 'cjs',
  autoExtension: false,
  output: {
    filename: {
      js: '[name].cjs'
    }
  }
// ...

Exepected

  • import xxx from './fooo.mjs' in esm output
  • aaa_require('./fooo.cjs') in cjs output

But got

  • import xxx from './fooo.js' in esm output
  • aaa_require('./fooo.js') in cjs output

Reproduce link

https://github.com/xc2/jbpr/blob/auto-extension-repro/sources/BUILD.ts

Reproduce Steps

ESM:

run pnpm rslib build -- //sources:esm and look into dist/lib

CJS:

run pnpm rslib build -- //sources:cjs and look into dist/lib

Metadata

Metadata

Assignees

Labels

🐞 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions