You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, passing regular expressions via define is not possible. Passing a RegExp fails with Expected value for define "__MY_REGEXP__" to be a string, got object instead while passing a string representation (/my[rR]eg[eE]xp/gm.toString()) fails with Invalid define value (must be an entity name or valid JSON syntax): /my[rR]eg[eE]xp/gm
It would be nice to have this easier, so that this workaround is not required anymore:
// esbuild config{// ...define: {__MY_REGEXP__: /my[rR]eg[eE]xp/gm,}}// index.jsconstmyRegExp=__MY_REGEXP__;// outputconstmyRegExp=/my[rR]eg[eE]xp/gm;// alternative output (replacement similar to objects and arrays)let__MY_REGEXP__=/my[rR]eg[eE]xp/gm;constmyRegExp=__MY_REGEXP__;
Passing a RegExp via CLI could be similar: --define:__MY_REGEXP__=/my[rR]eg[eE]xp/gm
The text was updated successfully, but these errors were encountered:
jxn-30
changed the title
Feature Request: Allow passing regular expressions (RegExp) via define when using JS/TS config
Feature Request: Allow passing regular expressions (RegExp) via defineDec 28, 2024
Currently, passing regular expressions via
define
is not possible. Passing a RegExp fails withExpected value for define "__MY_REGEXP__" to be a string, got object instead
while passing a string representation (/my[rR]eg[eE]xp/gm.toString()
) fails withInvalid define value (must be an entity name or valid JSON syntax): /my[rR]eg[eE]xp/gm
Current workaround:
It would be nice to have this easier, so that this workaround is not required anymore:
Passing a RegExp via CLI could be similar:
--define:__MY_REGEXP__=/my[rR]eg[eE]xp/gm
The text was updated successfully, but these errors were encountered: