build/lib/nls.ts/patch
	function patch(ts: typeof import('typescript'), moduleId: string, typescript: string, javascript: string, sourcemap: sm.RawSourceMap): INlsStringResult {
		const { localizeCalls, nlsExpressions } = analyze(ts, typescript);

		if (localizeCalls.length === 0) {
			return { javascript, sourcemap };
		}

		const nlsKeys = template(localizeCalls.map(lc => lc.key));
		const nls = template(localizeCalls.map(lc => lc.value));
		const smc = new sm.SourceMapConsumer(sourcemap);
		const positionFrom = mappedPositionFrom.bind(null, sourcemap.sources[0]);
		let i = 0;

		// build patches
		const patches = lazy(localizeCalls)
			.map(lc => ([
				{ range: lc.keySpan, content: '' + (i++) },
				{ range: lc.valueSpan, content: 'null' }
			]))
			.flatten()
			.map<IPatch>(c => {
				const start = lcFrom(smc.generatedPositionFor(positionFrom(c.range.start)));
				const end = lcFrom(smc.generatedPositionFor(positionFrom(c.range.end)));
				return { span: { start, end }, content: c.content };
			})
			.toArray();

		javascript = patchJavascript(patches, javascript, moduleId);

		// since imports are not within the sourcemap information,
		// we must do this MacGyver style
		if (nlsExpressions.length) {
			javascript = javascript.replace(/^define\(.*$/m, line => {
				return line.replace(/(['"])vs\/nls\1/g, `$1vs/nls!${moduleId}$1`);
			});
		}

		sourcemap = patchSourcemap(patches, sourcemap, smc);

		return { javascript, sourcemap, nlsKeys, nls };
	}