Closed MichaelPooleLF closed 2 months ago
Moving this to opensearch-js.
I have the same problem with the search method in the latest version of Next.js API.
Error in API: Error: Cannot find module '../api/_core/search'
Investigating. I suspect that it's webpack's handling of lazy loading.
From what I've gathered, it's not possible to lazy load relative paths in webpack without turning client.indices.create()
into (await client.indices).create()
due to the use of async import()
function. Lazy loading is just a nice-to-have feature in 3.0.0. We can get rid of it so the package works with Webpack and Next.js.
We're having the same issue with esbuild, cf https://esbuild.github.io/api/#glob
Thanks everyone! 3.0.0-beta.6 has been released which removed lazy loading and every require()
statement now uses literally string to help package managers like webpack grab all the needed files for bundling.
I've tested it locally with webpack, please lemme know if this version also resolves the issue for other frameworks as well.
This should be resolved, closing.
Describe the bug
Version 3.0.0-beta.5 of @opensearch-project/opensearch has an import error when building with webpack-cli version 1.5.4. Below is the error I received when attempting to build my project:
WARNING in ./node_modules/@opensearch-project/opensearch/api/utils.js 65:36-49 Critical dependency: the request of a dependency is an expression @ ./node_modules/@opensearch-project/opensearch/lib/OpenSearchAPI.js 18:32-55 @ ./node_modules/@opensearch-project/opensearch/lib/Client.js 49:22-48 @ ./node_modules/@opensearch-project/opensearch/index.js 32:19-42 @ ./src/services/getEsClient.ts 7:21-62 @ ./src/lambda/metricsGatherer.ts 10:22-56 WARNING in ./node_modules/@opensearch-project/opensearch/lib/OpenSearchAPI.js 28:26-39 Critical dependency: the request of a dependency is an expression @ ./node_modules/@opensearch-project/opensearch/lib/Client.js 49:22-48 @ ./node_modules/@opensearch-project/opensearch/index.js 32:19-42 @ ./src/services/getEsClient.ts 7:21-62 @ ./src/lambda/metricsGatherer.ts 10:22-56
Below is the error I received when attempting to execute code in an AWS Lambda:
{ "errorType": "Error", "errorMessage": "Cannot find module '../api/_core/index'", "code": "MODULE_NOT_FOUND", "stack": [ "Error: Cannot find module '../api/_core/index'", " at t (/var/task/app.js:2:268736)", " at E.index (/var/task/app.js:2:268342)", " at /var/task/app.js:2:511081", " at process.processTicksAndRejections (node:internal/process/task_queues:95:5)", " at async Promise.all (index 0)", " at async u.handler (/var/task/app.js:2:510307)" ] }
This error does not exist in @openseaerch-projejct/opensearch 2.11.0
Related component
Build
To Reproduce
This is not exact
Expected behavior
build will compile with warning: Critical dependency: the request of a dependency is an expression
Additional Details
No response