-
Notifications
You must be signed in to change notification settings - Fork 96
Cannot read property 'warn' of undefined when preferBuiltins is not set #196
Cannot read property 'warn' of undefined when preferBuiltins is not set #196
Comments
Just to check, are you using a fairly recent Rollup version? The plugin context for resolveId has not been around forever, I believe it was added in [email protected] |
Yes, that's with |
@lukastaegert anything else that comes to your mind? This came up in StencilJS project after almost a year of deployment without any issues. One of the changes in Stencil was actually the rollup update recently as @simonhaenisch already pointed out. |
There is in fact an issue with rollup-plugin-commonjs. During initialization, rollup-plugin-commonjs directly calls rollup-plugin-node-resolve in order to resolve the UPDATE: In fact, it is not during initialization but later. Fix pending. |
@lukastaegert I had a look at your PR... candidate.call(this, ...args) That means the |
I am running into this bug, with no
(stripped full path for readability) return resolveIdAsync(
importee,
Object.assign( resolveOptions, customResolveOptions )
)
.catch(function () { return false; })
.then(function (resolved) {
if (options.browser && packageBrowserField) {
if (packageBrowserField[ resolved ]) {
resolved = packageBrowserField[ resolved ];
}
browserMapCache[resolved] = packageBrowserField;
}
if ( !disregardResult && resolved !== false ) {
if ( !preserveSymlinks && resolved && fs.existsSync( resolved ) ) {
resolved = fs.realpathSync( resolved );
}
if ( ~builtins.indexOf( resolved ) ) {
return null;
} else if ( ~builtins.indexOf( importee ) && preferBuiltins ) {
if ( !isPreferBuiltinsSet ) {
this$1.warn(
"preferring built-in module '" + importee + "' over local alternative " +
"at '" + resolved + "', pass 'preferBuiltins: false' to disable this " +
"behavior or 'preferBuiltins: true' to disable this warning"
);
}
return null; Line 186 is this: this$1.warn(
"preferring built-in module '" + importee + "' over local alternative " +
"at '" + resolved + "', pass 'preferBuiltins: false' to disable this " +
"behavior or 'preferBuiltins: true' to disable this warning"
); adding an explicit |
@cellog you're referencing the same thing but the dist version rather than the source... there is already a PR that's fixing the missing |
rollup-plugin-node-resolve/src/index.js
Lines 177 to 183 in 73b01b1
When not having
preferBuiltins
set, I have a case where this piece of code throws an errorCan't give a reproducible example right now but just wondering whether this is considered a bug, or whether I'm doing something wrong to have
this
(the plugin context) beingundefined
? I just changed theresolveId
hook to log ifthis === undefined
and there were heaps of modules where that was the case, so I'm wondering whether there should be a'warn' in this
check before trying to throw a warning?As a workaround, setting
preferBuiltins
(to eithertrue
orfalse
) does the trick.Edit: The package/importee that caused this was
events
as a dependency of@featherjs/feathers
, and theresolveId
hook was called three times. The first timethis
was working and the warning came through, but then it was called again and that's whenthis
was undefined...This is the error being thrown:
So I think the calls actually came from
rollup-plugin-commonjs
(does it usenode-resolve
?), and maybe that's whythis
isn't set withinnode-resolve
, because the context is a different plugin (commonjs
)?The text was updated successfully, but these errors were encountered: