fix: handle ASI for export declaration

This commit is contained in:
inottn 2024-08-15 20:32:58 +08:00
parent 844fe4b2fa
commit 420cb39bdd
3 changed files with 21 additions and 0 deletions

View File

@ -166,6 +166,13 @@ module.exports = class HarmonyExportDependencyParserPlugin {
/** @type {DependencyLocation} */ (statement.loc)
);
dep.loc.index = idx;
const isAsiSafe = !parser.isAsiPosition(
/** @type {Range} */
(statement.range)[0]
);
if (!isAsiSafe) {
parser.setAsiPosition(/** @type {Range} */ (statement.range)[1]);
}
parser.state.current.addDependency(dep);
return true;
}

View File

@ -0,0 +1,3 @@
export const fn = (num) => {
return num;
};

View File

@ -0,0 +1,11 @@
import { fn } from './a.js';
const num = 1
export { num };
fn(num);
it("should work", function() {
expect(fn(num)).toBe(1);
});