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

config should use paths relative to mud.config.ts (project root) #596

Closed
holic opened this issue Apr 6, 2023 · 3 comments
Closed

config should use paths relative to mud.config.ts (project root) #596

holic opened this issue Apr 6, 2023 · 3 comments

Comments

@holic
Copy link
Member

holic commented Apr 6, 2023

I think in most places, any path args are relative to mud.config.ts, but we should firm that up as we consolidate configs.

We'll soon have a codegenDirectory (defaults to codegen) in #585 and that is now sort of implicitly coupled with storeImportPath, in that you need to specify or know the default codegen directory, then adjust your storeImportPath relative to that.

I propose we assume all paths are relative to mud.config.ts as a project root. So storeImportPath would look like

storeImportPath: `./src`

and codegen would detect this is a relative path (starts with .) and resolve the correct import path relative to the files being generated (path.relative(codegenFilePath, path.join(projectRoot, storeImportPath)))

Alternatively, for the specific issue above, we could remove the storeImportPath option and add a line to store's remappings.txt like

@latticexyz/store/src/=src/

That way imports of @latticexyz/store/* resolve to a local file rather than what's in e.g. node_modules

@dk1a
Copy link
Contributor

dk1a commented Apr 6, 2023

Alternatively, for the specific issue above, we could remove the storeImportPath option and add a line to store's remappings.txt like

that might be the best solution here assuming it works well for downstream consumers of store, like world (world wouldn't need such remappings, I just need to check if store having self-referential imports is fine)

@holic
Copy link
Member Author

holic commented Apr 6, 2023

that might be the best solution here assuming it works well for downstream consumers of store, like world (world wouldn't need such remappings, I just need to check if store having self-referential imports is fine)

Tried this in #598 and seems to blow up downstream. It seems to work within store itself, but when world imports a store thing and store tries to import from itself, the resolution path seems to be within world rather than store?

@holic
Copy link
Member Author

holic commented Oct 7, 2024

this is now done after some refactoring for multiple namespaces

@holic holic closed this as completed Oct 7, 2024
@github-project-automation github-project-automation bot moved this to Done in MUD Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants