requirejs-babel icon indicating copy to clipboard operation
requirejs-babel copied to clipboard

Do not append the .js extension to module names twice

Open prantlf opened this issue 4 years ago • 0 comments

Paths relative to the current directory include the file extension. But the recognition is not easy, because the name parameter passed to the plugin is not the original module name from the source code. For example:

import from 'src/sum'  ==> the plugin gets 'src/sum'
import from './sum'    ==> the plugin gets 'src/sum'
import from './sum.js' ==> the plugin gets 'src/sum.js'

RequireJS does not allow appending .js to module names from not relative paths. However, when writing a plugin, the ./ is not passed to it. As a workaround, I check if the name does not end with .js. Not the ultimate fix, but works probably well enough.

prantlf avatar Jan 02 '22 20:01 prantlf