Repository: NativeScript/NativeScript
File: packages/webpack5/src/configuration/base.ts (TypeScript)

Code before:
			}

			return defaultSourceMap;
		}

		// when --env.sourceMap=true is passed, use default
		if (typeof map === 'boolean' && map) {
			return defaultSourceMap;
		}

		// pass any type of sourceMap with --env.sourceMap=<type>
		return map as Config.DevTool;
	};

	const sourceMapType = getSourceMapType(env.sourceMap);

	// Use devtool for both CommonJS and ESM - let webpack handle source mapping properly
	config.devtool(sourceMapType);

	// For ESM builds, fix the sourceMappingURL to use correct paths
	if (!env.commonjs && sourceMapType && sourceMapType !== 'hidden-source-map') {
		class FixSourceMapUrlPlugin {
			apply(compiler) {
				compiler.hooks.emit.tap('FixSourceMapUrlPlugin', (compilation) => {
					Object.keys(compilation.assets).forEach((filename) => {
						if (filename.endsWith('.mjs') || filename.endsWith('.js')) {
							const asset = compilation.assets[filename];
							let source = asset.source();

							// Replace sourceMappingURL to use file:// protocol pointing to actual location
							source = source.replace(
								/\/\/# sourceMappingURL=(.+\.map)/g,
								`//# sourceMappingURL=file://${outputPath}/$1`,
							);

							compilation.assets[filename] = {
								source: () => source,
								size: () => source.length,
							};
						}
					});
				});
			}
		}

		config.plugin('FixSourceMapUrlPlugin').use(FixSourceMapUrlPlugin);
	}

	// when using hidden-source-map, output source maps to the `platforms/{platformName}-sourceMaps` folder
	if (env.sourceMap === 'hidden-source-map') {
		const sourceMapAbsolutePath = getProjectFilePath(

Review comment (suggestion):
```suggestion
          const leadingCharacter = process.platform === "win32" ? "/":"";
					Object.keys(compilation.assets).forEach((filename) => {
```

Code after:
			}

			return defaultSourceMap;
		}

		// when --env.sourceMap=true is passed, use default
		if (typeof map === 'boolean' && map) {
			return defaultSourceMap;
		}

		// pass any type of sourceMap with --env.sourceMap=<type>
		return map as Config.DevTool;
	};

	const sourceMapType = getSourceMapType(env.sourceMap);

	// Use devtool for both CommonJS and ESM - let webpack handle source mapping properly
	config.devtool(sourceMapType);

	// For ESM builds, fix the sourceMappingURL to use correct paths
	if (!env.commonjs && sourceMapType && sourceMapType !== 'hidden-source-map') {
		class FixSourceMapUrlPlugin {
			apply(compiler) {
				compiler.hooks.emit.tap('FixSourceMapUrlPlugin', (compilation) => {
          const leadingCharacter = process.platform === "win32" ? "/":"";
					Object.keys(compilation.assets).forEach((filename) => {
						if (filename.endsWith('.mjs') || filename.endsWith('.js')) {
							const asset = compilation.assets[filename];
							let source = asset.source();

							// Replace sourceMappingURL to use file:// protocol pointing to actual location
							source = source.replace(
								/\/\/# sourceMappingURL=(.+\.map)/g,
								`//# sourceMappingURL=file://${leadingCharacter}${outputPath}/$1`,
							);

							compilation.assets[filename] = {
								source: () => source,
								size: () => source.length,
							};
						}
					});
				});
			}
		}

		config.plugin('FixSourceMapUrlPlugin').use(FixSourceMapUrlPlugin);
	}

	// when using hidden-source-map, output source maps to the `platforms/{platformName}-sourceMaps` folder
	if (env.sourceMap === 'hidden-source-map') {