Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 5 warning "Should not import named export from default-exporting module" #1504

Closed
trivikr opened this issue Sep 8, 2020 · 6 comments · Fixed by #1505
Closed

Webpack 5 warning "Should not import named export from default-exporting module" #1504

trivikr opened this issue Sep 8, 2020 · 6 comments · Fixed by #1505
Labels
feature-request New feature or enhancement. May require GitHub community feedback.

Comments

@trivikr
Copy link
Member

trivikr commented Sep 8, 2020

Is your feature request related to a problem? Please describe.
When v3 is bundled using webpack@beta, the following warnings are shown:

[webpack-cli] Should not import the named export 'name' (imported as 'name') from default-exporting module (only default export is available soon)

[webpack-cli] Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon)

Quick test for bundling:

package.json
{
  "dependencies": {
    "@aws-sdk/client-dynamodb": "1.0.0-gamma.8"
  },
  "devDependencies": {
    "webpack": "5.0.0-beta.29",
    "webpack-cli": "4.0.0-beta.8"
  }
}
index.js
const { DynamoDB } = require("@aws-sdk/client-dynamodb");

(async () => {
  const client = new DynamoDB({});
  console.log(await client.listTables({ Limit: 1 }));
})();
$ ./node_modules/.bin/webpack --entry index.js --target=node
...
[webpack-cli] Should not import the named export 'name' (imported as 'name') from default-exporting module (only default export is available soon)

[webpack-cli] Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon)
...

Describe the solution you'd like
Webpack 5 is expected to released on 2020-10-10 as discussed in webpack/webpack#11406
Warning shouldn't be emitted when using AWS JS SDK v3

Describe alternatives you've considered
Ignoring the warning, as the application gets bundled and bundle file can be run without errors.

@trivikr trivikr added the feature-request New feature or enhancement. May require GitHub community feedback. label Sep 8, 2020
@trivikr
Copy link
Member Author

trivikr commented Sep 8, 2020

The bundling is successful, and bundled file runs without any errors:

$ node dist/main.js                                         
{
  ...
}

@trivikr
Copy link
Member Author

trivikr commented Sep 8, 2020

@trivikr
Copy link
Member Author

trivikr commented Sep 8, 2020

Refs: webpack/webpack#9246

@trivikr
Copy link
Member Author

trivikr commented Sep 16, 2020

Verified that the warning is no longer emitted with gamma.9 release.

package.json
{
  "dependencies": {
    "@aws-sdk/client-dynamodb": "1.0.0-gamma.9"
  },
  "devDependencies": {
    "webpack": "5.0.0-beta.29",
    "webpack-cli": "4.0.0-beta.8"
  }
}
index.js
const { DynamoDB } = require("@aws-sdk/client-dynamodb");

(async () => {
  const client = new DynamoDB({});
  console.log(await client.listTables({ Limit: 1 }));
})();
$ ./node_modules/.bin/webpack --entry index.js --target=node

✅ Compilation Results

🌏 Version: 5.0.0-beta.29
⚒️  Built: Wed Sep 16 2020 07:26:48 GMT-0700 (Pacific Daylight Time)
⏱  Compile Time: 9362ms
📂 Output Directory: /Users/trivikr/workspace/webpack-5-demo/dist
#️⃣ Hash: bfaa9b843a55b481a5c3

┌────────────┬──────────────────────────────────────────────────────────────────────────────────────────────┐
│ Entrypoint │ Bundle                                                                                       │
├────────────┼──────────────────────────────────────────────────────────────────────────────────────────────┤
│ main       │  Bundle Name       │ main.js                                                                 │
│            │  Compared For Emit │ false                                                                   │
│            │  Bundle size       │ 275.50 kb                                                               │
│            │                                                                                              │
│            │ Modules:                                                                                     │
│            │ ./index.js [size: 169 bytes]                                                                 │
│            │ ./node_modules/@aws-sdk/client-dynamodb/dist/es/index.js + 158 modules [size: 1000992 bytes] │
│            │ ./node_modules/@aws-sdk/client-dynamodb/dist/es/package.json [size: 2517 bytes]              │
│            │ ./node_modules/uuid/index.js [size: 120 bytes]                                               │
│            │ ./node_modules/uuid/lib/bytesToUuid.js [size: 775 bytes]                                     │
│            │ ./node_modules/uuid/lib/rng.js [size: 246 bytes]                                             │
│            │ ./node_modules/uuid/v1.js [size: 3331 bytes]                                                 │
│            │ ./node_modules/uuid/v4.js [size: 680 bytes]                                                  │
│            │ external "buffer" [size: 42 bytes]                                                           │
│            │ external "child_process" [size: 42 bytes]                                                    │
│            │ external "crypto" [size: 42 bytes]                                                           │
│            │ external "fs" [size: 42 bytes]                                                               │
│            │ external "http" [size: 42 bytes]                                                             │
│            │ external "http2" [size: 42 bytes]                                                            │
│            │ external "https" [size: 42 bytes]                                                            │
│            │ external "os" [size: 42 bytes]                                                               │
│            │ external "path" [size: 42 bytes]                                                             │
│            │ external "process" [size: 42 bytes]                                                          │
│            │ external "stream" [size: 42 bytes]                                                           │
│            │ external "url" [size: 42 bytes]                                                              │
│            │ webpack/runtime/compat get default export [size: 263 bytes]                                  │
│            │ webpack/runtime/define property getters [size: 308 bytes]                                    │
│            │ webpack/runtime/hasOwnProperty shorthand [size: 86 bytes]                                    │
│            │ webpack/runtime/make namespace object [size: 274 bytes]                                      │
└────────────┴──────────────────────────────────────────────────────────────────────────────────────────────┘

[webpack-cli] configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

@trivikr
Copy link
Member Author

trivikr commented Sep 16, 2020

For future reference, verified that gamma.9 works with rollup, esbuild.
An issue is created for parcel at #1529

Rollup
$ ./node_modules/.bin/rollup --version                     
rollup v2.27.0

$ ./node_modules/.bin/rollup index.js --file dist/bundle.js
index.js → dist/bundle.js...
created dist/bundle.js in 41ms
esbuild
$ ./node_modules/.bin/esbuild --version
0.7.1

$ ./node_modules/.bin/esbuild --bundle index.js --platform=node --outdir=dist

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request New feature or enhancement. May require GitHub community feedback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant