Skip to content

Replace plugin: Does not work as expected with .ts config #5802

@TheAlexLichter

Description

@TheAlexLichter

Do I use the experimental plugin wrong or is it not working for the case below (compared to the rollup one)

Example / Demo

Config:

import type { RolldownOptions } from 'rolldown'
import rollupReplacePlugin from '@rollup/plugin-replace'
import { replacePlugin } from 'rolldown/experimental'
const config: RolldownOptions = {
  input: './src/index.ts',
  plugins: [
    replacePlugin({
      __rolldown: '0'
    }),
    rollupReplacePlugin({
      __rollup: '1',
      preventAssignment: true
    })
  ]
}

export default config
// index.ts

// @ts-ignore
console.log(__rollup, __rolldown)

Expected output:

console.log(1, 0);

Actual:

console.log(1, __rolldown);

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions