[BUG] Broken imports on browser builds
Tezirg opened this issue · 3 comments
Before you begin...
- I have searched the existing issues
- I am not using version 13.x of node (if so, please upgrade)
Description of the problem
Hello,
I noticed the v4() imports of unsafeStringify
are not correct, the stringify.js file should NOT use BOTH default and named exports
WARNING in ./node_modules/uuid/dist/esm-browser/v4.js 26:9-24
Can't import the named export 'unsafeStringify' (imported as 'unsafeStringify') from default-exporting module (only default export is available)
@ ./node_modules/uuid/dist/esm-browser/index.js 3:0-40 3:0-40
That leads to the following error when bundled with Webpack AND when Crypto API is not available:
CommonJs:
TypeError: (0 , a.unsafeStringify) is not a function
ESM:
TypeError: (void 0) is not a function
Recipe for reproducing
The tests & examples are not quite good enough to detect this, since it requires to have the crypto API disabled:
Using a linux distribution and the browser-webpack example:
- add `127.0.0.1 uuidbug` to the `/etc/hosts` file
- add & configure webpack5 devServer
- add `allowedHosts: "uuidbug"` to the Webpack5 `devServer` configuration
- start the dev server
- Navigate to http://uuidbug:<localport>/example-v4.html
Additional information
Had to rollback to 7.0.3, so 8.x AND 9.x are concerned
Environment
System:
OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
Memory: 18.36 GB / 31.02 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.14.0 - /usr/local/bin/node
Yarn: 1.22.18 - ~/.yarn/bin/yarn
npm: 8.3.1 - /usr/local/bin/npm
Browsers:
Chrome: 110.0.5481.77
Firefox: 112.0
npmPackages:
@babel/core: ^7.21.0 => 7.21.0
@babel/eslint-parser: ^7.19.1 => 7.19.1
@babel/plugin-proposal-class-properties: 7.5.5 => 7.5.5
@babel/plugin-proposal-object-rest-spread: 7.6.2 => 7.6.2
@babel/preset-env: 7.6.3 => 7.6.3
@babel/preset-flow: 7.0.0 => 7.0.0
@babel/preset-react: 7.6.3 => 7.6.3
@babel/runtime: 7.6.3 => 7.6.3
@reduxjs/toolkit: ^1.9.3 => 1.9.3
babel-jest: ^29.5.0 => 29.5.0
babel-loader: ^9.1.0 => 9.1.2
chai: ^4.2.0 => 4.3.7
copy-webpack-plugin: ^11.0.0 => 11.0.0
core-js: ^3.29.0 => 3.29.0
cross-env: ^7.0.0 => 7.0.3
css-loader: ^6.7.0 => 6.7.3
debug: ^4.1.1 => 4.3.4
enzyme: ^3.10.0 => 3.11.0
enzyme-adapter-react-16: ^1.15.0 => 1.15.7
eslint: ^8.35 => 8.35.0
eslint-config-airbnb: ^19.0.0 => 19.0.4
eslint-plugin-flowtype: ^8.0.0 => 8.0.3
eslint-plugin-jsx-a11y: ^6.7.0 => 6.7.1
eslint-plugin-react: ^7.32.0 => 7.32.2
html-webpack-plugin: ^5.5.0 => 5.5.0
jest: ^29.5.0 => 29.5.0
jest-environment-jsdom: ^29.5.0 => 29.5.0
jest-junit-reporter: ^1.1.0 => 1.1.0
mock-socket: ^8.1.1 => 8.1.1
moment: ^2.29.4 => 2.29.4
prettier: ^2.8.0 => 2.8.4
prop-types: ^15.8.0 => 15.8.1
react: ^16.10.2 => 16.14.0
react-art: ^16.10.2 => 16.13.1
react-css-transition-replace: ^4.0.0 => 4.0.5
react-dom: ^16.10.2 => 16.14.0
react-intl: ^2.9.0 => 2.9.0
react-redux: ^8.0.0 => 8.0.5
react-router: ^6.8.0 => 6.8.2
react-router-dom: ^6.8.0 => 6.8.2
react-style-proptype: ^3.2.2 => 3.2.2
redux: ^4.0.4 => 4.2.1
redux-mock-store: ^1.5.3 => 1.5.4
redux-thunk: ^2.3.0 => 2.4.2
style-loader: ^3.3.0 => 3.3.1
uuid: ^9.0.0 => 9.0.0
webpack: ^5.75.0 => 5.78.0
webpack-cli: ^5.0.0 => 5.0.1
webpack-dev-server: ^4.11.0 => 4.11.1
webpack-merge: ^5.8.0 => 5.8.0
the stringify.js file should NOT use BOTH default and named exports
This is valid in ESM, so I think that the issue is with one of the tools you are using.
I have a hard time imagining that WebPack 5 doesn't support this, since it's a very widely used tool 🤔
I started to reproduce this but got stuck on this step:
add & configure webpack5 devServer
Can you please add the exact steps to take to get a Minimal Reproducible Example?
Marking as stale due to 90 days with no activity.
Closing issue due to 30 days since being marked as stale.