Feature suggestion: alternate path separator to '.'
I'm trying to auto-generate package.json files:
The new "exports" syntax has dots . in the key itself.
I tried using pathval and obviously couldn't set a deep export entry: setPathValue(pkg_json, 'exports..', './index.js');
I ended up coding my own utility which allows an alternate separator | and will automatically pick it if the key starts with it: setPathValue(pkg_json, '|exports|.', './index.js');
I understand that my use case may not be the one from this package.
This is a friendly sharing + helping future users. Feel free to mark this issue as resolved.
And thanks for the lib and for chai 👏
i wonder if we should make it possible to pass an array of parts, setPathValue(obj, ['foo', '.', 'bar']) etc
@43081j good idea, but in my personal use case, I wanted the key/value to be storable in a JSON, ex.
{
overrides: {
package_json: {
'|exports|.', './index.js',
},
},
},
hence the need for (string -> string)
Once again, I understand that my use case may be very specific.
we already supported escaped dots it seems!
you can do this:
setPathValue(obj, 'exports.\\.');
. to separate keys, \\. is a key itself