diff --git a/packages/cli/package.json b/packages/cli/package.json index 3431f884a..be077207e 100755 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "nanachi-cli", - "version": "1.8.27", + "version": "1.8.28", "description": "cli tool for nanachi", "bin": { "nanachi": "./bin/index.js" diff --git a/packages/cli/packages/babelPlugins/proposalOptionalChaining.js b/packages/cli/packages/babelPlugins/proposalOptionalChaining.js index 36a3df241..864bf680d 100644 --- a/packages/cli/packages/babelPlugins/proposalOptionalChaining.js +++ b/packages/cli/packages/babelPlugins/proposalOptionalChaining.js @@ -63,6 +63,7 @@ module.exports = ((api, options) => { const { object } = chain; let context = scope.maybeGenerateMemoised(object); if (context) { + scope.removeBinding(context.name); chain.object = core_1.types.assignmentExpression('=', context, object); } else if (core_1.types.isSuper(object)) { diff --git a/src/cli/packages/babelPlugins/proposalOptionalChaining.ts b/src/cli/packages/babelPlugins/proposalOptionalChaining.ts index 2b1e3eaef..531c99994 100644 --- a/src/cli/packages/babelPlugins/proposalOptionalChaining.ts +++ b/src/cli/packages/babelPlugins/proposalOptionalChaining.ts @@ -86,6 +86,8 @@ module.exports = ((api, options: Options) => { let context = scope.maybeGenerateMemoised(object); if (context) { + // 移除关联关系 + scope.removeBinding(context.name); chain.object = t.assignmentExpression('=', context, object); } else if (t.isSuper(object)) { context = t.thisExpression();