8000 webpack bundling and "module has no exports" · Issue #162 · avoidwork/filesize.js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
webpack bundling and "module has no exports" #162
Closed
@skratchdot

Description

@skratchdot

Hey! First off thanks for making this great library!

I just tried upgrading filesize from v9 to v10.

After changing my imports from:

import filesize from 'filesize'

to:

import { filesize } from 'filesize'

I thought things would work, but when I ran my app, I saw the following webpack error when visiting my site:

export 'filesize' (imported as 'filesize') was not found in 'filesize' (module has no exports)

I was able to "fix" the issue by adding the following resolve alias to my webpack config:

    resolve: {
      alias: {
        filesize: require.resolve('filesize'),
      },
    },

My project is using typescript, and I think a fairly standard webpack setup.

I did a little searching, and I've seen a few people mention that changing the "browser" field from a string to a map might force webpack to pick the "module" over the "browser" field?

I think my build was using the browser field by default and that doesn't have exports?

webpack/webpack#4674 (comment)

https://github.com/defunctzombie/package-browser-field-spec

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0