Repository: import-js/eslint-plugin-import (js)

Issue:
eslint-plugin-import silently fails if the module is minified
I have 2 files:

1. test.js
```
import { bogus } from './bogus.js';

bogus()
```

2. bogus.js
```
function foo() {
    console.log('foo');
}

export {
    foo
}
```

If `bogus.js` is minified, eslint-plugin-import silently fails:

```
$ npx eslint js/test.js        # Working case

/home/user/test/js/test.js
  1:10  error  bogus not found in './bogus.js'  import/named

✖ 1 problem (1 error, 0 warnings)

$ npx minify js/bogus.js > bogus2.js
$ mv bogus2.js js/bogus.js
$ npx eslint js/test.js        # Silent failure case
$
```

Here's my eslint config:
```
import globals from "globals";
import pluginJs from "@eslint/js";
import importPlugin from "eslint-plugin-import";

/** @type {import('eslint').Linter.Config[]} */
export default [
  importPlugin.flatConfigs.recommended,
  {languageOptions: { globals: globals.browser }},
  pluginJs.configs.recommended,
];
```

Tested with eslint 8.X and 9.X, issue is present in both. Using `eslint-plugin-import:2.31.0`

Edit: Actually, some types of minification work. For example:
```
function a(){console.log("foo")};export{a}; // works
function a(){console.log("foo")}export{a}; // doesn't work
```

Is this library using regex or something to detect exports instead of the file's AST? That's the only thing I can think of that would make it so that the absence of an optional semicolon causes silent failures

Pull request description:
[utils] [fix] `unambiguous`: detect modules exported from minified code
This change adjusts the regex pattern used to detect modules to support detection on minified code.

![image](https://github.com/user-attachments/assets/e66fc8a9-131f-4701-8af3-b84984c1cfe9)

Closes #3107 


Patch:
diff --git a/utils/CHANGELOG.md b/utils/CHANGELOG.md
index bb937251..fe7381a2 100644
--- a/utils/CHANGELOG.md
+++ b/utils/CHANGELOG.md
@@ -5,6 +5,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
 
 ## Unreleased
 
+### Fixed
+- `unambiguous`: detect modules exported from minified code ([#3124], thanks [@michaelfaith])
+
 ### Changed
 - [refactor] `parse`: avoid using a regex here (thanks [@ljharb])
 
@@ -180,6 +183,7 @@ Yanked due to critical issue with cache key resulting from #839.
 ### Fixed
 - `unambiguous.test()` regex is now properly in multiline mode
 
+[#3124]: https://github.com/import-js/eslint-plugin-import/pull/3124
 [#3072]: https://github.com/import-js/eslint-plugin-import/pull/3072
 [#3061]: https://github.com/import-js/eslint-plugin-import/pull/3061
 [#3057]: https://github.com/import-js/eslint-plugin-import/pull/3057
@@ -230,6 +234,7 @@ Yanked due to critical issue with cache key resulting from #839.
 [@JounQin]: https://github.com/JounQin
 [@kaiyoma]: https://github.com/kaiyoma
 [@leipert]: https://github.com/leipert
+[@ljharb]: https://github.com/ljharb
 [@manuth]: https://github.com/manuth
 [@maxkomarychev]: https://github.com/maxkomarychev
 [@mgwalker]: https://github.com/mgwalker
@@ -238,6 +243,7 @@ Yanked due to critical issue with cache key resulting from #839.
 [@nicolo-ribaudo]: https://github.com/nicolo-ribaudo
 [@pmcelhaney]: https://github.com/pmcelhaney
 [@sergei-startsev]: https://github.com/sergei-startsev
+[@silverwind]: https://github.com/silverwind
 [@sompylasar]: https://github.com/sompylasar
 [@timkraut]: https://github.com/timkraut
 [@vikr01]: https://github.com/vikr01
diff --git a/utils/unambiguous.js b/utils/unambiguous.js
index 20aabd1b..df7b9be7 100644
--- a/utils/unambiguous.js
+++ b/utils/unambiguous.js
@@ -2,7 +2,7 @@
 
 exports.__esModule = true;
 
-const pattern = /(^|;)\s*(export|import)((\s+\w)|(\s*[{*=]))|import\(/m;
+const pattern = /(^|[;})])\s*(export|import)((\s+\w)|(\s*[{*=]))|import\(/m;
 /**
  * detect possible imports/exports without a full parse.
  *


Test patch:
diff --git a/tests/files/minified/no-newline.js b/tests/files/minified/no-newline.js
new file mode 100644
index 00000000..261989a7
--- /dev/null
+++ b/tests/files/minified/no-newline.js
@@ -0,0 +1,3 @@
+function y() {
+    console.log("y");
+}export {y};
diff --git a/tests/files/minified/one-line-no-semi-renamed.js b/tests/files/minified/one-line-no-semi-renamed.js
new file mode 100644
index 00000000..601f9c7b
--- /dev/null
+++ b/tests/files/minified/one-line-no-semi-renamed.js
@@ -0,0 +1,1 @@
+function a(){console.log('foo')}export{a as foo};
diff --git a/tests/files/minified/one-line-no-semi.js b/tests/files/minified/one-line-no-semi.js
new file mode 100644
index 00000000..09a63281
--- /dev/null
+++ b/tests/files/minified/one-line-no-semi.js
@@ -0,0 +1,1 @@
+function a(){return true}export{a};
diff --git a/tests/files/minified/one-line.js b/tests/files/minified/one-line.js
new file mode 100644
index 00000000..b79898eb
--- /dev/null
+++ b/tests/files/minified/one-line.js
@@ -0,0 +1,1 @@
+function a(){console.log("foo")};export{a};
diff --git a/tests/src/core/getExports.js b/tests/src/core/getExports.js
index f11a2613..a02edb85 100644
--- a/tests/src/core/getExports.js
+++ b/tests/src/core/getExports.js
@@ -465,6 +465,10 @@ describe('ExportMap', function () {
       ['bar.js', true],
       ['deep-es7/b.js', true],
       ['common.js', false],
+      ['./minified/no-newline.js', true],
+      ['./minified/one-line-no-semi-renamed.js', true],
+      ['./minified/one-line-no-semi.js', true],
+      ['./minified/one-line.js', true],
     ];
 
     for (const [testFile, expectedRegexResult] of testFiles) {