Require.js compiler generates inaccurate source codes

I am using tool.js build tool (via grunt-contrib-requirejs) to collect all my code in a mini version and I have included generateSourceMaps.

However, the required source code is the wrong creation. In some files they are fine, in others - along one or two lines; in some - 17 lines. What could be wrong?

Perhaps weird things about my repo:

  • handle templates built into the assembly (they are precompiled using the Alex Sexton plugin )
  • several files that do not include the standard code code (cordova, trunk, puppet).
  • I use r.js to concatenate files, but not to minimize them. Minimizing files does not fix the problem (the same line errors occur).
  • in some configurations, r.js gives an error that says it cannot generate source maps if preserveLicenseComments is enabled. In other cases (when they are not minimized), it seems that there are no problems with observing the comments to the license. In any case, turning it off, you will not be able to correct line numbers.
  • the files listed below in the sourcemap header have larger errors.

What could be the reason for this and how to fix it?

UPDATE I narrowed this down: the sourcemap generator loses a line every time it hits a line like this:

console.log('l170');     // logs as on line 170
//>>excludeStart('excludeHbsParser', pragmas.excludeHbsParser)
console.log('l172');     // logs as on line 171

I'm not quite sure what the r.js parser does with these lines, but it doesn't seem to take them into account properly in sourcemap generation.

+4
source share

Source: https://habr.com/ru/post/1528840/


All Articles