Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Bug: Rollup plugin-replace: preventAssignment set to "false" #302

Closed
Christian-Rau opened this issue Feb 23, 2021 · 11 comments
Closed

Bug: Rollup plugin-replace: preventAssignment set to "false" #302

Christian-Rau opened this issue Feb 23, 2021 · 11 comments

Comments

@Christian-Rau
Copy link

So today I got this notification, and not sure what to do about it, as I don't see any preventAssignment anywhere.
• service worker @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option totrue, as the next major version will default this option to true.
• server
@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to true, as the next major version will default this option to true.
• client
@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to true, as the next major version will default this option to true.
• service worker
@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to true, as the next major version will default this option to true.
`

@Christian-Rau Christian-Rau changed the title Rollup plugin-replace: preventAssignment set to "false" Bug: Rollup plugin-replace: preventAssignment set to "false" Feb 23, 2021
@exodus4d
Copy link

exodus4d commented Feb 23, 2021

Ref: rollup/plugins@659ed59
Doku: https://github.com/rollup/plugins/tree/master/packages/replace#preventassignment

@Conduitry Conduitry transferred this issue from sveltejs/sapper Feb 23, 2021
@Conduitry
Copy link
Member

Transferring this to the sapper-template repo. It probably makes sense to make the @rollup/plugin-replace dependency be ^2.4.0 and add this option in rollup.config.js.

@didiermun
Copy link

i have the same error and don't know why it is rising. Waiting for solution

@antony
Copy link
Member

antony commented Feb 26, 2021

@didiermunezero the solution is posted directly above your comment. Add preventAssignment: true to your rollup config.

It's also not an error, it's a warning, and does not stop you continuing unimpeded

@Christian-Rau
Copy link
Author

Christian-Rau commented Feb 26, 2021 via email

@didiermun
Copy link

@didiermunezero the solution is posted directly above your comment. Add preventAssignment: true to your rollup config.

It's also not an error, it's a warning, and does not stop you continuing unimpeded

Yeah now it works, thank you. But why not make it true by default as you know that it will give a warning??

@antony
Copy link
Member

antony commented Feb 27, 2021

That's quite literally what the warning is telling you, that it will become the default in the next release.

But I'm not sure why you're commenting here - we aren't the authors of rollup-plugin-replace and as such have no part in the decision process.

@didiermun
Copy link

oh that is cool and thanks! @antony

@guther
Copy link

guther commented Mar 6, 2021

You need to insert preventAssignment: true, in all instances of replace, like this:

plugins: [
	replace({
		preventAssignment: true,
		'process.browser': true,
		'process.env.NODE_ENV': JSON.stringify(mode)
	}),

@Christian-Rau
Copy link
Author

Closed since it's not a bug, and the sapper template, has been updated.

@shijiezhou1
Copy link

You need to insert preventAssignment: true, in all instances of replace, like this:

plugins: [
	replace({
		preventAssignment: true,
		'process.browser': true,
		'process.env.NODE_ENV': JSON.stringify(mode)
	}),

Insert and still getting the same warning

tylerlaws0n added a commit to tylerlaws0n/elderjs that referenced this issue Sep 11, 2021
sveltejs/sapper-template#302
https://github.com/rollup/plugins/tree/master/packages/replace#preventassignment

```sh
Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
```
nickreese pushed a commit to Elderjs/elderjs that referenced this issue Nov 12, 2021
sveltejs/sapper-template#302
https://github.com/rollup/plugins/tree/master/packages/replace#preventassignment

```sh
Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants