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

Code before:
			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(
			`./${
				env.buildPath ?? 'platforms'
			}/${platform}-sourceMaps/[file].map[query]`,
		);
		const sourceMapRelativePath = relative(outputPath, sourceMapAbsolutePath);
		config.output.sourceMapFilename(sourceMapRelativePath);
	}

Review comment (suggestion):
```suggestion
								`//# sourceMappingURL=file://${leadingCharacter}${outputPath}/$1`,
```
For chrome to pick up the local file on windows you need `file:///C:\asdasd`  i.e. 3 forward slashes after the `file:` which you automatically get on unix like file systems.

Code after:
			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') {
		const sourceMapAbsolutePath = getProjectFilePath(
			`./${
				env.buildPath ?? 'platforms'
			}/${platform}-sourceMaps/[file].map[query]`,
		);
		const sourceMapRelativePath = relative(outputPath, sourceMapAbsolutePath);
		config.output.sourceMapFilename(sourceMapRelativePath);