Repository: swc-project/swc (rust)

Issue:
Number to Fixed unexpected error
### Describe the bug

Hello everyone. 

I have a problem i am using the latest swc/core but when i use this kind of code it throws an error
`var hasToFixedBugs = (1000000000000000128).toFixed(0) !== '1000000000000000128'` it should keep the parenthesis and transform to string and then fixed to 0 but it removed and tries number to fixed 

```
var hasToFixedBugs = 1000000000000000128.toFixed(0) !== '1000000000000000128';
                     ^^^^^^^^^^^^^^^^^^^^

SyntaxError: Invalid or unexpected token
```

`npm ls`

```
├── @swc-node/register@1.5.1
├── @swc/cli@0.1.57
├── @swc/core@1.2.223
```

### Input code

_No response_

### Config

_No response_

### Playground link

_No response_

### Expected behavior

keep the parenthesis

### Actual behavior

_No response_

### Version

1.2.223

### Additional context

_No response_

Pull request:
fix(es/codegen): emit extra dot when float is too large
<!-- Note: CI script will automatically rebase your PR so please do not rebase unless required -->

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. -->

**Description:**

The original implementation is not only slow, but also problematic when float is too large so toString would lose precision 

**BREAKING CHANGE:**

<!--
If this PR introduces a breaking change, it must contain a notice for it to be included in the CHANGELOG. Add description or remove entirely if not breaking.

You may need to update `MIGRATION.md` for the breaking changes.
-->

**Related issue (if exists):**
closes #5397 

Patch:
diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs
index 880d8be22b..3b59029053 100644
--- a/crates/swc_ecma_codegen/src/lib.rs
+++ b/crates/swc_ecma_codegen/src/lib.rs
@@ -636,9 +636,10 @@ where
         Ok(striped_raw
             .map(|raw| {
                 if raw.bytes().all(|c| c.is_ascii_digit()) {
-                    // Legacy octal contains only digits, but `value` and `raw` are
-                    // different
-                    if !num.value.to_string().eq(&raw) {
+                    // Maybe legacy octal
+                    // Do we really need to support pre es5?
+                    let slice = raw.as_bytes();
+                    if slice.len() >= 2 && slice[0] == b'0' {
                         return false;
                     }
 


Test patch:
diff --git a/crates/swc/tests/fixture/issues-5xxx/5397/input/index.js b/crates/swc/tests/fixture/issues-5xxx/5397/input/index.js
new file mode 100644
index 0000000000..2c30c3b5ba
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5397/input/index.js
@@ -0,0 +1,1 @@
+var hasToFixedBugs = (1000000000000000128).toFixed(0) !== "1000000000000000128";
diff --git a/crates/swc/tests/fixture/issues-5xxx/5397/output/index.js b/crates/swc/tests/fixture/issues-5xxx/5397/output/index.js
new file mode 100644
index 0000000000..a41bd24824
--- /dev/null
+++ b/crates/swc/tests/fixture/issues-5xxx/5397/output/index.js
@@ -0,0 +1,1 @@
+var hasToFixedBugs = 1000000000000000128..toFixed(0) !== "1000000000000000128";