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

Also have node_modules/ taglibs default to ./components? #1401

Open
tigt opened this issue Aug 19, 2019 · 6 comments
Open

Also have node_modules/ taglibs default to ./components? #1401

tigt opened this issue Aug 19, 2019 · 6 comments

Comments

@tigt
Copy link
Contributor

tigt commented Aug 19, 2019

Marko Version: 4.18.10

Details

When using a Marko project in a root project, components will automatically be discovered at ./components.

When using a custom taglib from node_modules/, the compiler requires "tags-dir" to be defined.

Expected Behavior

I assumed as long as marko.json existed, the autoloader would reuse the ./components convention.

Possible Fix

Either this difference should be more clearly documented, OR

The autoloader should also have a default of .components if "tags-dir" isn’t defined. I’d much prefer this option.

Steps to Reproduce

https://github.com/tigt/marko-cant-import-internal-package-repro

Stack Trace

Error: An error occurred while trying to compile template at path "~/repo/src/components/SiteHead/components/SiteSearch/SiteSearch.marko". Error(s) in template:
    1) [src/components/SiteHead/components/SiteSearch/SiteSearch.marko:8:4] Unrecognized tag: Button - More details: https://github.com/marko-js/marko/wiki/Error:-Unrecognized-Tag
@DylanPiercey
Copy link
Contributor

In this case are you hoping to avoid having a marko.json at all? If so we currently use that as one of the heuristics for if we should scan a module for components.

@tigt
Copy link
Contributor Author

tigt commented Feb 4, 2020

No, I had a marko.json with a taglib ID already. I was genuinely surprised Marko didn’t assume components/ with it, as it seemed logical that it would use the default autodiscovery behavior it does everywhere else.

@DylanPiercey
Copy link
Contributor

I agree. We should make this change.

@DylanPiercey
Copy link
Contributor

Thinking this through a bit more, this would actually be a breaking change.

Also I think in a lot of cases packages may opt for something like ./src/components and so maybe this is not a sane default?

@tigt
Copy link
Contributor Author

tigt commented Feb 5, 2020

I would be fine if it gave an error message saying “it looks like you’re trying to use these components, but you have to use an explicit tags-dir”. I was confused for a while with the generic Unrecognized tag error.

@DylanPiercey
Copy link
Contributor

I think that's something we could do. Basically if a marko.json does not register any tags we could maybe log a warning.

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