Closed maier49 closed 7 years ago
No coverage report found for master at 6269ae6.
Powered by Codecov. Last update 6269ae6...343632a
Where is globalObject.require
being set? If an application is being built with webpack and therefore using its internal loader, there would be no require
in the global namespace.
This came up within the context of building our tests. When we run the tests with Intern it's still going to use its own loader so there will be a require in the global namespace. If there isn't one this effectively reverts back to its original behavior.
I don't think we should land this in its current form for the following reasons:
The current require code in cli-build
gives context require support to webpack without an AMD loader giving parity in functionality. For toUrl
and toAbsMid
in this, that would not be the case which would be confusing in my opinion.
This boilerplate would be added to every point a contextual require is made (regardless of whether .toUrl
or .toAbsMid
is used) which seems like a overhead in bundle size.
You can actually use require.toUrl
with a contextual require in AMD - which this doesn't support.
When we move to the version of intern that is loaderless, we won't have an AMD loader anyway, so it seems like in the mean time we might be better just changing the way we access an html page in todo-mvc to not use require.toUrl
?
@matt-gadd I agree with that reasoning.
It does bring up one other concern though. This code is currently triggering on usage of require.toUrl
. If it actually was a contextual require it will still be replaced with a function without a toUrl
method, meaning that using require.toUrl
with a contextual require is not supported by the current version either. Unless I'm missing something in how that would work.
Type: bug
The following has been addressed in the PR:
Description:
Currently, if code is calling
require.toUrl
, that will trigger theexpression require
condition and that module will haverequire = function() { return '${path}'; }
prepended to it. However, this function obviously doesn't have atoUrl
property so the call will fail. Checking for usages ofrequire.toUrl
and not replacing require at all is problematic because webpack will still replace it with__webpack_require__
which doesn't have atoUrl
function either.It seems like there should probably be a better way to handle this. But this does work for todoMVC at least.