developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.07k stars 363 forks source link

No name was provided for external module #223

Closed zzswang closed 4 years ago

zzswang commented 6 years ago

I always get following output in console.

What does it mean? Need to fix it or just let it go?

No name was provided for external module 'http-errors' in output.globals – guessing 'createError'

Thanks.

developit commented 6 years ago

it only matters if you're running your bundle as a <script src> and using browser globals. Are you transpiling for node, or the browser?

zzswang commented 6 years ago

bundle es module for both node and browser

zzswang commented 6 years ago

the http-errors' repo

https://github.com/jshttp/http-errors

FezVrasta commented 5 years ago

To give a bit more clarity on the matter, this warning matters, as @developit explained, only if you are importing the bundle using the <script src> tag, because it will look for its dependencies in the global namespace.

This means that, inside your bundle, you will not have require('http-errors'), but window.createError (since that's the name Rollup guessed for you).

Ideally there should be a way to specify the names manually, maybe by command-line if we don't want to add a microbundle config file.

microbundle --external http-errors createError --external @emotion/core emotionCore
zzswang commented 5 years ago

@FezVrasta

Thank you, it is very clear and helpful.

FezVrasta commented 5 years ago

@developit if this isn't something you'd like to support I think those warnings should be disabled

zzswang commented 5 years ago

or we just make it automatically?

since it has already got the right guess "createError".

FezVrasta commented 5 years ago

That's what's already happening, hence my idea to hide the warning (in case we don't want to provide a way to override the default behavior)

maiertech commented 4 years ago

Following-up on this warning. After upgrading to v0.12.0 I see this warning for each dependency. For instance,

No name was provided for external module 'prop-types' in output.globals – guessing 'propTypes'

This is related to the UMD build. Not sure what I am supposed to configure here to make the warning go away. Maybe this could be clarified in the README?

Since my package does not need a UMD modules, I work around this issue by specifying the module types I support with --format. This makes the warning go away.

MarkLyck commented 4 years ago

I'm having the same warning, but I do want the UMD modules. So I can't simply fix it with --format

developit commented 4 years ago

You can fix this by passing --globals prop-types=propTypes.

MarkLyck commented 4 years ago

You can fix this by passing --globals prop-types=propTypes.

@developit But I have like 25 of them 😰

No name was provided for external module '@fortawesome/fontawesome-svg-core' in output.globals – guessing 'fontawesomeSvgCore'
No name was provided for external module '@fortawesome/free-solid-svg-icons' in output.globals – guessing 'freeSolidSvgIcons'
No name was provided for external module 'react-grid-layout' in output.globals – guessing 'RGL'
No name was provided for external module 'styled-components' in output.globals – guessing 'styled'
No name was provided for external module 'react-markdown' in output.globals – guessing 'ReactMarkdown'
No name was provided for external module '@fortawesome/react-fontawesome' in output.globals – guessing 'reactFontawesome'
No name was provided for external module 'date-fns' in output.globals – guessing 'dateFns'
No name was provided for external module 'react-virtualized' in output.globals – guessing 'reactVirtualized'
No name was provided for external module '@material-ui/core/CircularProgress' in output.globals – guessing 'CircularProgress'
No name was provided for external module '@antv/data-set' in output.globals – guessing 'DataSet'
No name was provided for external module 'date-fns/format' in output.globals – guessing 'format'
No name was provided for external module 'date-fns/subDays' in output.globals – guessing 'subDays'
No name was provided for external module 'date-fns/differenceInHours' in output.globals – guessing 'differenceInHours'
No name was provided for external module '@material-ui/core/FormControlLabel' in output.globals – guessing 'FormControlLabel'
No name was provided for external module '@material-ui/core/Checkbox' in output.globals – guessing 'Checkbox'
No name was provided for external module '@material-ui/icons/RadioButtonChecked' in output.globals – guessing 'RadioButtonChecked'
No name was provided for external module '@material-ui/icons/RadioButtonUnchecked' in output.globals – guessing 'RadioButtonUnchecked'
No name was provided for external module '@material-ui/core/Table' in output.globals – guessing 'Table'
No name was provided for external module '@material-ui/core/TableBody' in output.globals – guessing 'TableBody'
No name was provided for external module '@material-ui/core/TableCell' in output.globals – guessing 'TableCell'
No name was provided for external module '@material-ui/core/TableHead' in output.globals – guessing 'TableHead'
No name was provided for external module '@material-ui/core/TableRow' in output.globals – guessing 'TableRow'
No name was provided for external module '@cubejs-client/react' in output.globals – guessing 'react'
No name was provided for external module 'colony-admin' in output.globals – guessing 'colonyAdmin'
No name was provided for external module 'react-pose' in output.globals – guessing 'posed'

That would be a crazy long command to set that for everything?

The main problem seems to be that e.g. @material-ui/core is installed, but to achieve minimal bundle size I import just the stuff I need from e.g. @material-ui/core/TableCell and it doesn't know that this actually does exist?

developit commented 4 years ago

Hmm - material-ui isn't even available as UMD modules, so this isn't something Microbundle can fix in the first place.

If you're bundling an application (sounds like you are?) You should pass --external none to tell Microbundle to include all of these dependencies into your own bundle. Alternatively, if you move material-ui from dependencies to devDependencies in your package.json, it will be inlined.

ForsakenHarmony commented 4 years ago

Will close for now, leave a comment if this is still an issue

namjul commented 3 years ago

Encountering this issue I have been wondering why with scoped npm packages this warning appears and with non-scoped npm packages not. I found that scoped packages don't pass the following check: https://github.com/developit/microbundle/blob/fa3eac6f491288ff3b8cfd2812eecd350c7a2316/src/index.js#L337

Curious if this is intented.