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

Relative imports are not supported #2

Open
ivan-c opened this issue Jul 12, 2022 · 3 comments
Open

Relative imports are not supported #2

ivan-c opened this issue Jul 12, 2022 · 3 comments

Comments

@ivan-c
Copy link
Member

ivan-c commented Jul 12, 2022

In my attempt to support development with docker, I've been trying to store node dependencies outside the git checkout.

When I tried installing node_modules into the parent directory of the git checkout (see notes), I got the below error.

From this SO question, it sounds like a restriction from create-react-app.

Relative import error:
Attaching to sof-client-dev_frontend_1
frontend_1  | 
frontend_1  | > hello-world-react@0.1.0 start /opt/app
frontend_1  | > rescripts start
frontend_1  | 
frontend_1  | ℹ 「wds」: Project is running at http://192.168.32.2/
frontend_1  | ℹ 「wds」: webpack output is served from 
frontend_1  | ℹ 「wds」: Content not from webpack is served from /opt/app/public
frontend_1  | ℹ 「wds」: 404s will fallback to /
frontend_1  | Starting the development server...
frontend_1  | 
frontend_1  | Failed to compile.
frontend_1  | 
frontend_1  | ./src/components/Summary.js
frontend_1  | Module not found: You attempted to import ../../node_modules/cql-worker/src/cql.worker.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
@achen2401
Copy link
Contributor

@ivan-c I saw that the error was related to importing the cql worker lib in node_modules folder, Does this resolve the error?

@ivan-c
Copy link
Member Author

ivan-c commented Jul 12, 2022

@ivan-c I saw that the error was related to importing the cql worker lib in node_modules folder, Does this resolve the error?

Yup, thank you!

If I understand correctly, you fixed the issue by replacing a relative import with an absolute one. However, I was wondering if you won't be able to use relative imports at all, and if that's even a problem.

Since the immediate problem is solved, feel free to close this issue after your PR is merged

@achen2401
Copy link
Contributor

If I understand correctly, you fixed the issue by replacing a relative import with an absolute one. However, I was wondering if you won't be able to use relative imports at all, and if that's even a problem.

@ivan-c For importing node_modules components/libs, I am able to use both absolute path and relative path in my own local instance (which is not docker built). But I can see the flaw in using the relative path if the location of the node_modules directory has changed as in this situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants