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

Latest versions fail #1046

Open
avoinea opened this issue May 13, 2024 · 13 comments
Open

Latest versions fail #1046

avoinea opened this issue May 13, 2024 · 13 comments
Labels
bug Something isn't working

Comments

@avoinea
Copy link

avoinea commented May 13, 2024

�[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 avoinea added the bug Something isn't working label May 13, 2024
@Samiul-TheSoccerFan
Copy link
Contributor

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

@Samiul-TheSoccerFan
Copy link
Contributor

@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.

@avoinea
Copy link
Author

avoinea commented May 15, 2024

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

@Samiul-TheSoccerFan
Copy link
Contributor

@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.

@gaving
Copy link

gaving commented May 24, 2024

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:-

v1.21.2...v1.21.3

We'll pin this on 1.21.2 for now!

@joemcelroy
Copy link
Member

joemcelroy commented May 24, 2024

Hi there,

We recently introduced an update where we declared exports within the package json. (#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 (#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

@gaving
Copy link

gaving commented May 24, 2024

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.

@joemcelroy
Copy link
Member

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

@joemcelroy
Copy link
Member

joemcelroy commented Jun 6, 2024

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
Copy link
Member

@avoinea in 1.21.5, you can now access helpers via

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

@gaving
Copy link

gaving commented Jun 6, 2024

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
Copy link

gaving commented Jun 6, 2024

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

@joemcelroy
Copy link
Member

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.

tiberiuichim added a commit to eea/volto-cca-policy that referenced this issue Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants