Forgets to export the namespace
alecmev opened this issue · 9 comments
In markdown-toc
, module.exports
is missing after the transformation. Seems like unlazy-loader
is expecting some other convention.
In case anybody else stumbles into this before it's fixed, here's my current workaround:
module: {
loaders: [
{
test: /markdown-toc\/lib\/utils\.js$/,
loader: 'exports?utils!unlazy',
},
...
exports-loader
merely appends module.exports = utils;
to the end of the matching files.
Seems like unlazy-loader is expecting some other convention.
I think you're right. sounds like a bug, or markdown-toc is using an unsupported format and needs to be updated. I'll take a look
hmm, what version of markdown-toc is causing the issue?
It's 0.12.3, the latest.
@jeremejevs are you using unlazy-loader@0.1.1
?
There's a test fixture that is using the same signature as markdown-toc
and that's passing.
Yep, 0.1.1, installed it today.
I've done a quick test, to make sure that module.exports
isn't missing before invoking unlazy
. I've replaced exports?utils!unlazy
with unlazy!exports?utils
(= added a second exports
) - same issue (i.e. unlazy-loader
has removed both exports
).
The non-lazy
test does indeed look like markdown-toc
. Not sure what's the issue.
How are you testing this? Is it happening when using unlazy-loader
directly or only when used in webpack
? Could this be an issue with webpack
?
This is in a normal development setup (with hot-loading, source maps, whole shebang). Here's what I'm observing in the browser (using Chrome development tools, I can browse module sources):
- With
exports?utils!unlazy
I seemodule.exports
inutils.js
and get no exceptions - With
unlazy
orunlazy!exports?utils
I see nomodule.exports
inutils.js
and I get an exception, pointing out thatutils.Remarkable
isn't a function
I had my doubts about this being Webpack's / my config's fault, until I tried unlazy!exports?utils
.
@jeremejevs thank you for trying out different scenarios. I added the markdown-toc
to the tests and tracked down the bug. Fix is published to npm as 0.1.2
. Feel free to re-open if this doesn't work for you.
Can confirm, it's fixed now. Much appreciated!