Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

mixed-typed property names (some with delimiters) #13

Closed
yairEO opened this issue Jan 10, 2017 · 2 comments
Closed

mixed-typed property names (some with delimiters) #13

yairEO opened this issue Jan 10, 2017 · 2 comments

Comments

@yairEO
Copy link

yairEO commented Jan 10, 2017

How can I do mixed replace? (some variables have delimiters and some don't:

replace({
    "delimiters" : [ '[', ']' ],
    "SERVERPATH" : JSON.stringify(config.serverPath),   // <---- requires delimiters
    "prodUrl"    : JSON.stringify(config.prodUrl),      // <---- requires delimiters
    "mocks/"     : JSON.stringify(config.serverPath + '/mocks/') 
})

It was an utter failure to not use the delimiters key and trying to manually write [SERVERPATH] as key name. I also tried to escape the key like \[SERVERPATH\] without output success .

@yairEO yairEO closed this as completed Jan 10, 2017
@yairEO yairEO changed the title fails to replace with "Expecting Unicode escape sequence \uXXXX" error mixed-typed variable names (some with delimiters, some not) Jan 11, 2017
@yairEO yairEO reopened this Jan 11, 2017
@yairEO yairEO changed the title mixed-typed variable names (some with delimiters, some not) mixed-typed property names (some with delimiters) Jan 11, 2017
@mrkishi
Copy link
Contributor

mrkishi commented Jan 16, 2017

It's not possible without patching rollup-plugin-replace.

I submitted a PR that fixes this, but it hasn't been merged. Until then, I'm using that branch as a dependency instead of the published npm package.

@Rich-Harris
Copy link
Contributor

Special characters are now supported in keys thanks to @mrkishi, so I'll close this. An alternative solution would be just to have two plugin instances — one with delimiters, one without.

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

3 participants