marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.4k stars 644 forks source link

Custom taglibs not found after migrating to v3 #252

Closed tbashor closed 8 years ago

tbashor commented 8 years ago

I just migrated to v3 and now only custom taglibs in the same directory as the page are resolved.

Here's a sample of the directory structure:

root
   package.json
   marko.json
   node_modules
   plugins
      components
         my-hello
             template.marko
      pages
         test
            page.marko

marko.json has:

{
  "tags-dir": [
    "./plugins/components"
  ]
}

I can get the my-hello custom tag to render in page.marko only when it and marko.json are located in /plugins/pages/test.

I believe related to this issue, <init-widgets/> and <browser-refresh/> don't render either. They appear as tags in the outputted page.

It was my understanding that marko would walk up the directory tree from the page to the project's root looking for marko.json. Once found, it would use marko.json to pull in any custom tag definitions. I'm not sure what changed with v3.

patrick-steele-idem commented 8 years ago

@tbashor by any chance, do you have any intermediate package.json files? The taglib finder stops when it gets to the "root" of the package? The root of the package is determined by looking for a package.json file with a "name" property. I suspect that the search for taglibs is being ended prematurely due to the root directory not being as expected. FYI, here is the code that is used to discover taglibs for marko: https://github.com/marko-js/marko/blob/master/compiler/taglib-finder/index.js

Please let me know if that is the case. Thanks.

tbashor commented 8 years ago

Walking up the directory tree from plugins/pages/test, I only have package.json at the root. Some of the other plugins have a package.json file but they are not parents of the test page.

Did this behavior change between v2 and v3? I ask because in the v2 version of the repo I’m working on I have a page directory with a package.json and everything is working fine.

From: Patrick Steele-Idem notifications@github.com Reply-To: marko-js/marko reply@reply.github.com Date: Sunday, March 20, 2016 at 1:40 PM To: marko-js/marko marko@noreply.github.com Cc: Todd Bashor tbashor@gmail.com Subject: Re: [marko] Custom taglibs not found after migrating to v3 (#252)

@tbashor by any chance, do you have any intermediate package.json files? The taglib finder stops when it gets to the "root" of the package? The root of the package is determined by looking for a package.json file with a "name" property. I suspect that the search for taglibs is being ended prematurely due to the root directory not being as expected. FYI, here is the code that is used to discover taglibs for marko: https://github.com/marko-js/marko/blob/master/compiler/taglib-finder/index.js

Please let me know if that is the case. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

patrick-steele-idem commented 8 years ago

@tbashor We did change the logic for discovering taglibs to address some problems. It's linked to from the What's New in Marko v3, but here is the relevant Github issue with details: https://github.com/marko-js/marko/issues/224

From that description of what changed do you see any issue that would be impacting your project? If needed, we can always adjust things slightly, but from what I can tell your project should be fine as long as there are no additional package.json files that are causing the root directory to be different than one what is expected. Since your plugins have package.json files it seems like that might be the cause, but I don't fully understand your project structure.

If you are able to create a minimal project to reproduce the problem that would be helpful.

patrick-steele-idem commented 8 years ago

@tbashor also, here are the relevant docs: http://markojs.com/docs/marko/custom-taglibs/#taglib-discovery

tbashor commented 8 years ago

@patrick-steele-idem You were right that there was a package.json stopping the lookup. I'm still having trouble getting the lasso tags to resolve, but I think that has to do with my particular setup. Thanks for your help.

patrick-steele-idem commented 8 years ago

Thanks for the update @tbashor. Let me know if you run into any other issues and glad to see that you have migrated to Marko v3.