mirror of
https://github.com/SonarSource/sonarqube-scan-action.git
synced 2026-05-18 17:30:17 +03:00
NO-JIRA Make rollup build reproducible across line endings
Normalize CRLF to LF in the rollup load hook so Windows checkouts produce the same dist bundle and source maps as Linux/macOS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+15
-1
@@ -16,9 +16,23 @@
|
||||
// along with this program; if not, write to the Free Software Foundation,
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||
|
||||
// Ensures CRLF line endings from a Windows checkout don't leak into the
|
||||
// bundle or the source map's sourcesContent, so the build is reproducible
|
||||
// across operating systems. Uses `load` rather than `transform` so the
|
||||
// normalized text is also what Rollup embeds in sourcesContent.
|
||||
const normalizeLineEndings = {
|
||||
name: "normalize-line-endings",
|
||||
load(id) {
|
||||
if (id.startsWith("\0") || id.includes("?")) return null;
|
||||
const code = readFileSync(id, "utf8");
|
||||
return code.includes("\r") ? code.replaceAll("\r\n", "\n") : null;
|
||||
},
|
||||
};
|
||||
|
||||
const config = {
|
||||
input: [
|
||||
"src/main/index.js",
|
||||
@@ -30,7 +44,7 @@ const config = {
|
||||
format: "es",
|
||||
sourcemap: true,
|
||||
},
|
||||
plugins: [commonjs(), nodeResolve({ preferBuiltins: true })],
|
||||
plugins: [normalizeLineEndings, commonjs(), nodeResolve({ preferBuiltins: true })],
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
Reference in New Issue
Block a user