Skip to content

Commit 20bf0e5

Browse files
authored
fix: do not replace dollar sign in shim variable name (#200)
1 parent b135c90 commit 20bf0e5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

hook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ async function processModule ({ srcUrl, context, parentGetSource, parentResolve,
254254
addSetter(name, setter, true)
255255
}
256256
} else {
257-
const variableName = `$${n.replace(/[^a-zA-Z0-9_]/g, '_')}`
257+
const variableName = `$${n.replace(/[^a-zA-Z0-9_$]/g, '_')}`
258258
const objectKey = JSON.stringify(n)
259259
const reExportedName = n === 'default' || NODE_MAJOR < 16 ? n : objectKey
260260

test/fixtures/invalid-identifier.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ exports['one.two'] = () => console.log('b')
33

44
// See: https://github.com/nodejs/import-in-the-middle/issues/94
55
exports['unsigned short'] = 'something'
6+
7+
exports._ = 'foo'
8+
exports.$ = 'bar'

0 commit comments

Comments
 (0)