Skip to content

Upgrading to the latest version 4.1.0 is not compatible with *.mjs files. #59

Open

Description

@ChrisGao2016

Our project uses xlsx@0.18.5 and imports the xlsx.mjs file. However, beginning with version 4.1.0, the dependency switched to node-stdlib-browser, causing the buffer to downgrade to version 5.x. The buffer 5.x version only includes the common module, which is not compatible with the project's reference to *.mjs files, leading to webpack build errors.

Activity

  1. Richienb commented on Dec 10, 2024

    @Richienb
    Owner

    @ChrisGao2016 buffer@6.0.3 also seems to use commonjs. Are you sure your issue is resolved by downgrading to node-polyfill-webpack-plugin@4.0.0?

    Maybe there's a different cause?

  2. Richienb commented on Dec 10, 2024

    @Richienb
    Owner

    @niksy Worth updating the buffer package anyways?

  3. niksy commented on Dec 10, 2024

    @niksy

    Let’s see if this really is issue with buffer module, but I don’t see why not, except I would like to bump it to major version. I’m not sure if this can break other dependants.

  4. gabrielbarretoo commented on Dec 10, 2024

    @gabrielbarretoo

    Same bug here. Any solution?

  5. Rukato commented on Jan 10, 2025

    @Rukato

    I was able to solve the issue by setting the yaml inter-dependency version to the latest. This solved the issue of the breaking change where it could not find an index.js file. The error I was seeing was:

    ERROR in ./node_modules/yaml/browser/dist/warnings-df54cb69.js 24:15-21 Module not found: Error: Can't resolve '[workspace/project]/node_modules/buffer' in '[workspace/project]/node_modules/yaml/browser/dist' Did you mean 'index.js'? BREAKING CHANGE: The request '[workspace/project]/node_modules/buffer' failed to resolve only because it was resolved as fully specified (probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'). The extension in the request is mandatory for it to be fully specified. Add the extension to the request. resolve '[workspace/project]/node_modules/buffer' in '[workspace/project]/node_modules/yaml/browser/dist' using description file: [workspace/project]/node_modules/yaml/browser/dist/package.json (relative path: .) Field 'browser' doesn't contain a valid alias configuration root path [workspace/project] using description file: /[workspace/project]/package.json (relative path: .[workspace/project]/node_modules/buffer) Field 'browser' doesn't contain a valid alias configuration [workspace/project]/[workspace/project]/node_modules/buffer doesn't exist using description file: [workspace/project]/package.json (relative path: ./node_modules/buffer) Field 'browser' doesn't contain a valid alias configuration [workspace/project]/node_modules/buffer is not a file @ ./node_modules/yaml/browser/dist/index.js 5:0-51 978:11-15 @ ./node_modules/yaml/browser/index.js 1:0-39 @ ./node_modules/redoc/bundles/redoc.browser.lib.js 2:92854-92869 @ ./src/pages/docs/api_docs.tsx 3:0-40 14:84-99 @ ./src/AuthApp.tsx 14:0-48 28:144-151 @ ./src/App.tsx 10:0-32 19:36-43 @ ./src/index.tsx 3:0-24 6:73-76

    I was able to solve it by setting this on my package.json
    "resolutions": { "buffer": "6.0.3", "yaml":"2.7.0" },

  6. charlesritchea commented on Feb 12, 2025

    @charlesritchea

    This just happened to me with axios and process. Downgrading to 4.0.0 fixed it as well

  7. axetroy commented on Mar 4, 2025

    @axetroy

    buffer is not a dual package, Downgrade to 4.0.0 and it works.

  8. peter-cardenas-ai commented on Mar 17, 2025

    @peter-cardenas-ai

    downgrading to 4.0.0 to fix issues with rrweb worked for me

  9. kotarella1110 commented on May 12, 2025

    @kotarella1110

    It seems the issue is caused by a change in how the plugin specifies the path to the buffer module.

    In version v4.0.0 the ProvidePlugin was configured like this:

    new webpack.ProvidePlugin({
      Buffer: ['/Users/xxx/project/node_modules/buffer/index.js', 'Buffer'],
      // ...
    });

    However, in v4.1.0, it was changed to the following:

    new webpack.ProvidePlugin({
      Buffer: ['/Users/xxx/project/node_modules/buffer', 'Buffer'],
      // ...
    });

    This change seems to break module resolution for buffer.

    As a workaround, adding the following rule to the webpack config allows buffer to be resolved correctly:

    module: {
      rules: [
        {
          test: /\.m?js$/,
          resolve: {
            fullySpecified: false
          }
        }
      ]
    }
  10. ChrisGao2016 commented on May 14, 2025

    @ChrisGao2016
    Author

    It seems the issue is caused by a change in how the plugin specifies the path to the buffer module.

    In version v4.0.0 the ProvidePlugin was configured like this:

    new webpack.ProvidePlugin({
    Buffer: ['/Users/xxx/project/node_modules/buffer/index.js', 'Buffer'],
    // ...
    });
    However, in v4.1.0, it was changed to the following:

    new webpack.ProvidePlugin({
    Buffer: ['/Users/xxx/project/node_modules/buffer', 'Buffer'],
    // ...
    });
    This change seems to break module resolution for buffer.

    As a workaround, adding the following rule to the webpack config allows buffer to be resolved correctly:

    module: {
    rules: [
    {
    test: /.m?js$/,
    resolve: {
    fullySpecified: false
    }
    }
    ]
    }

    It seems that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions