search-ui icon indicating copy to clipboard operation
search-ui copied to clipboard

Latest versions fail

Open avoinea opened this issue 9 months ago • 13 comments

[91mModule not found: Error: Package path ./lib/cjs/helpers is not exported from package /app/node_modules/@elastic/search-ui (see exports field in /app/node_modules/@elastic/search-ui/package.json)
ModuleNotFoundError: Module not found: Error: Package path ./lib/cjs/helpers is not exported from package /app/node_modules/@elastic/search-ui (see exports field in /app/node_modules/@elastic/search-ui/package.json)
    at /app/node_modules/webpack/lib/Compilation.js:2016:28
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:798:13
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:270:22
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:434:22
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:116:11
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:670:25
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:855:8
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:975:5
    at /app/node_modules/neo-async/async.js:6883:13
    at /app/node_modules/webpack/lib/NormalModuleFactory.js:958:45
    at finishWithoutResolve (/app/node_modules/enhanced-resolve/lib/Resolver.js:567:11)
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:656:15
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /app/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:89:43
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /app/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:89:43
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /app/node_modules/enhanced-resolve/lib/Resolver.js:714:5
    at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /app/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js:41:15
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
[0mThe command '/bin/sh -c yarn   && yarn build   && rm -rf /home/node/.cache   && rm -rf /home/node/.yarn   && rm -rf /home/node/.npm   && rm -rf /app/.yarn/cache' returned a non-zero code: 1
script returned exit code 1

Pinning version to 1.21.2 fixed the issue for me.

avoinea avatar May 13 '24 18:05 avoinea

@avoinea : Thank you for letting us know. We will investigate and get back to you soon.

Samiul-TheSoccerFan avatar May 13 '24 20:05 Samiul-TheSoccerFan

@avoinea : Can you provide more details on the error and/or how to reproduce the issue (preferably a link to Codesandbox)? I have successfully run a sample application with the latest version defined in here.

Samiul-TheSoccerFan avatar May 13 '24 23:05 Samiul-TheSoccerFan

@Samiul-TheSoccerFan https://github.com/eea/eea-website-frontend/tree/develop

avoinea avatar May 15 '24 13:05 avoinea

@avoinea : We do not recommend importing directly from the files import { removeSingleFilterValue } from '@elastic/search-ui/lib/cjs/helpers';. It might create issues in the long run such as moving the interfaces or files into a different location.

Samiul-TheSoccerFan avatar May 17 '24 16:05 Samiul-TheSoccerFan

Hi!

This has broken our build due to an automerge rule from our renovate tool.

Currently using search-ui-elasticsearch-connector like so:-

import APIConnector from "@elastic/search-ui-elasticsearch-connector";

According to https://docs.elastic.co/search-ui/api/connectors/elasticsearch

Resulting in:-

image

Has this import to be changed?

Concerned a patch semver change between 1.21.2 and 1.21.3 has knackered our build:-

https://github.com/elastic/search-ui/compare/v1.21.2...v1.21.3

We'll pin this on 1.21.2 for now!

gaving avatar May 24 '24 10:05 gaving

Hi there,

We recently introduced an update where we declared exports within the package json. (https://github.com/elastic/search-ui/pull/1043). We made this change as a patch as it should of been backwards compatible and was addressing a bug with it not able to be used by libraries which rely on ESM imports (https://github.com/elastic/search-ui/pull/1043).

However this change may have impacted those who bundlers that now using the exports path and having issues now with loading search-ui with ESM.

@gaving could you give me more context on your setup? How is your code bundled? nextjs / CRA etc. Will try replicate on my end.

Joe

joemcelroy avatar May 24 '24 10:05 joemcelroy

Hi @joemcelroy -

Thanks for the quick response.

Nothing too complicated it seems to reproduce:-

❯ node --version
v18.19.1
npm i --save '@elastic/search-ui-elasticsearch-connector'

Add

"type": "module"

to package.json

index.js

import APIConnector from "@elastic/search-ui-elasticsearch-connector";
❯ node index.js
(node:20790) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/tmp/test_build/index.js:1
import APIConnector from "@elastic/search-ui-elasticsearch-connector";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1274:20)
    at Module._compile (node:internal/modules/cjs/loader:1320:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49

Node.js v18.19.1

Verified on Node 20.13.1 too for what it's worth.

gaving avatar May 24 '24 10:05 gaving

Thanks. Will follow what we did in Searchkit where the file extension is mjs.

joemcelroy avatar May 24 '24 11:05 joemcelroy

Update: This is becoming a little more difficult to do as now issue arises downstream due to searchkit not esm compatible yet. We are planning on removing searchkit as a dependency in the upcoming GAing.

For now use 1.20.1 @gaving - i dont want to create additional issues arising from making further changes. We will address this properly soon as we evaluate dependencies and ESM compatibility.

joemcelroy avatar Jun 06 '24 10:06 joemcelroy

@avoinea in 1.21.5, you can now access helpers via

import { ViewHelpers } from '@elastic/react-search-ui-views';

joemcelroy avatar Jun 06 '24 10:06 joemcelroy

Update: This is becoming a little more difficult to do as now issue arises downstream due to searchkit not esm compatible yet. We are planning on removing searchkit as a dependency in the upcoming GAing.

For now use 1.20.1 @gaving - i dont want to create additional issues arising from making further changes. We will address this properly soon as we evaluate dependencies and ESM compatibility.

Funnily enough our CI just bumped, tested & merged 1.21.5 automatically? All appears good this side!

gaving avatar Jun 06 '24 11:06 gaving

Ah sorry, disregard - that was @elastic/react-search-ui, the connector is still broke.

gaving avatar Jun 06 '24 11:06 gaving

just to highlight - this is an issue if you're using node directly, without a transpile step like typescript or vite. These transpilers handle different resolution strategies for dependencies so depending on your build setup, it may work fine.

joemcelroy avatar Jun 06 '24 19:06 joemcelroy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Is this issue still important to you? If so, please leave a comment and let us know. As always, thank you for your contributions.

botelastic[bot] avatar Aug 05 '24 20:08 botelastic[bot]

Is this issue still important to you? If so, please leave a comment and let us know. As always, thank you for your contributions.

This issue is still important to us!

gaving avatar Aug 13 '24 06:08 gaving

Just to be clear, is this definitely a wontfix?

Running a server side service with:-

import APIConnector from "@elastic/search-ui-elasticsearch-connector";

Isn't possible to be run using node directly?

Just unsure if there's a suggested workaround is (i.e. without transpiling).

gaving avatar Oct 17 '24 12:10 gaving