DanielSchaffer/webpack-babel-multi-target-plugin

TypeError: Cannot read property 'descriptionFileRoot' of undefined

Closed this issue · 11 comments

Hi! Thank you for the great plugin letting us make (IT, world) more progressive! But. I came across the next problems:

  1. ERROR in .?babel-target=legacy Module not found: TypeError: Cannot read property 'descriptionFileRoot' of undefined @ .?babel-target=legacy 8:14-39

Reproducable repo: https://github.com/shurygindv/reproducable-babel-multi-target

  1. I can't find the bottleneck of this problem, but I have only such message (uses awesome-ts-loader, without options,tsconfig has target esnext)

ERROR in ./src/components/A.tsx?babel-target=legacy Module not found: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean

p.s I'm sure module presents there and it pretty works without plugin

any ideas? let me hope that it may be fixed... or right way is to fork this repo and write own bike

Hi there! Looks like this is a bug in how modules loaded via require.context are handled. I'll have to do a little digging to figure out specifically what's going on.

@shurygindv Looks like this was a pretty easy fix - try v2.3.3-next.2

@DanielSchaffer, thank you so much! an error seems disappeared, but I haven't tried runtime yet, as there is (2) problem, as mentioned before in a post, could you help?

In my opinion 1 line on 14 position looks good, need your eagle-eyed...

Capture

p.s sorry, I didn't find out a feature to hide it in spoiler;

Looks like there's some sort of compatibility issue with bloodhound-js. It's possible there's some sort of conflict if there's a dependency on es6-promise, since Promises would be polyfilled by Babel/core-js separately. I'll see if I can track it down.

ok, thx) also I have similar errors with local UI modern components (.tsx files) (self-writеtten by the team) + bloodhound, damn it! I had spoken my team why we need so legacy pkg

Okay, figured it out - es6-promise had some data in their package.json in a format I wasn't expecting - a false value in the browser object (used to ignore a file - see https://github.com/defunctzombie/package-browser-field-spec#ignore-a-module). I've added code to correctly handle that now.

I was also seeing some weird behavior with @babel/preset-env and core-js, which I solved by setting the default options for @babel/preset-env to use core-js version 2.

Try 2.3.3-next.3.

Just a heads up that this plugin is set up to use Babel with preset-env set to useBuiltins: 'usage' - which means that given your browser targets, it will automatically add polyfills as they're needed. This could mean that for legacy browsers you'd end up with Promise polyfills from both es6-promise, as it's included explicitly in that dependency's code, and from core-js, when it's injected by Babel. At best, it's a waste of bytes in your bundle - at worst, there could be some weird side effects due to conflicting polyfills. I'd recommend researching if there's a way to avoid loading that es6-promise polyfill - possibly by either using an alternate package which does not include it, or maybe even by using a resolve setting in your Webpack config to prevent it from getting loaded.

It looks like bloodhound isn't even maintained any more - it hasn't seen a commit in over 4 1/2 years. It might be better idea to find an alternative package or method. Are you using any frontend framework (Angular, React, Vue, etc)?

@DanielSchaffer, yes, we use React + TypeScript (awesome-ts-loader), the bloodhound is an echo from a previous, legacy stack; we had a short time and cup of tea to integrate all codebase on a new modern stack, but right now I initiate the process to replace this package

@DanielSchaffer, gracious 💃 ! finally, I can bundle without errors, it's a magic fix (+ I'll set corejs on '3' version). Thank you!

p.s modern/legacy bundle pretty works in runtime
p.s when do you plan to release a new version of the plugin?)

This is now released in 2.3.3