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
When there's comment at the beginning, the first span of AST node is always starting with 0, instead of actual position of first non-comment code position in the original code
Input code
/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */'use strict';
for 1st non comment code "use strict" directive, the output AST is showing span from 0. It should be the position of that string literal from original code.
We're using span to get the position of the code, and delete them from the original code. For instance, A rollup plugin is checking "use client" directives and trying to delete it from the original code.
Actually lo and hi is BytePos so it's expected. There's no good way to use source location from JS plugin, and JS plugin is going to be deprecated anyway.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
When there's comment at the beginning, the first span of AST node is always starting with 0, instead of actual position of first non-comment code position in the original code
Input code
Config
No response
Playground link
https://play.swc.rs/?version=1.3.74&code=H4sIAAAAAAAAA0WOyw6CQAxF93zF3aEExcfSJcGERN3ID2inyEQyJZ1hwd87k2hc9vTe01ZFkaFALdOi9jUErGiNw25%2F3EzKnl0ocX4QP0XeJVpH25hOhW6wHl5mJQaJYcRxtMTOs8HsDCvCwLi23Q%2Bjl8hhXVokxaWtm9u9QW9H%2FmKoSICxyhREF0gf6f9QUOb0QJVl%2BRyNPqilkJ%2ByDz%2Bh%2BQvGAAAA&config=H4sIAAAAAAAAA2VRsY7DMAjd%2BxURc4dTxttu7NCPsHykci82FhCpUZV%2FL6RJmugWC97j8QA%2FT00Dd4nw3TwttKQGFuQtN0TGouFhCOhYUSKnqnBeWRWnlAeckelNgAa%2BoboIpf1q20UAPZGgwV3oBddaDkU64rx3ZQxRd4BDQ9GUXQ1hUMpBU4SFng7uOZXUjft2kXJlFDlae2kot36b6NAFHxXZDG39ft%2FrD7FeciXWH7FbaaIi%2F24wP59BNlNIcqXfYbZ0xbtsRZZP8EP7mjZ1pnIX33I6TS9UUQp0rgEAAA%3D%3D
Expected behavior
for 1st non comment code
"use strict"
directive, the output AST is showing span from0
. It should be the position of that string literal from original code.Actual behavior
No response
Version
1.3.74
Additional context
We're using span to get the position of the code, and delete them from the original code. For instance, A rollup plugin is checking
"use client"
directives and trying to delete it from the original code.x-ref: huozhi/rollup-preserve-directives#9
The text was updated successfully, but these errors were encountered: