JetBrains/web-types

Can I use web-types in Goland without package.json?

nkev opened this issue ยท 15 comments

nkev commented

Does the web-types system have a dependency on NPM?

I don't use npm or package.json but I want to use the HTMX webtype in JetBrains Goland.

Is this possible?

@nkev so far web-types support in WebStorm works only with package.json. But I would love to extend that. Could you please explain a little bit more on how are you using HTMX in your project, specifically, what kind of a build system manages the HTMX dependency?

nkev commented

Thanks @piotrtomiak. My build system is very simple and uses Goland's built-in File Watchers to process SCSS and JS bundles:

image

I don't like having hundreds of NPM dependencies, so I manually keep a lib folder with subfolders of libraries. Whenever there is a change in my source files or library files the Goland File Watchers run automatically. I just followed the IntelliJ docs to achieve this and it works well for me. Here is my library structure (scss folder is hidden here, below lib folder):

image

Thanks for the explanation. I assume that in lib/htmx for instance there is just the JS file, isn't it?

nkev commented

No problem. No, the lib/htmx package is actually quite complex with many extensions in the ext folder. It even has a web-types file in the jetbrains folder :)

image

Thank you for the example! It looks like any autodetection mechanism wouldn't work for you. You would need a preference page, where you can explicitly specify, which web-types file to enable, correct?

nkev commented

Yes, I think a generic Jetbrains "Web Types" dialog would be more configurable and more explicit than automatically traversing project files to find **/*.web-types files. Maybe the dialog could list the *.web-types files it found as a starting point.

I second this need. :-) Doing a pure HTML/JS page with some custom web-components and getting a lot of "Unknown html tag".

Hi there. We also need such a feature, really much. Current "package.json" implementation lacks a lot of power.

For example, a package.json in subfolder overrides the web-types from it parents. You have a root folder with web-types in package.json, you have a subfolder with no web-types in package.json. Result: In all files edited in this subfolder you will have no web-types support what so ever. Bad for a module based development, where your root contains all base features and components.

In can think of ways to solve this:

  • Having separate files with a naming convention that are automatically detected by the IDE, like .editorconfig (This would i prefer)
  • Having all package.json sum up and not override each other web-types
  • Additionally having an option in the scheme, to decide if it is a "root" node, so if this will reset inheritance of parents or not

Our current workaround is: We have the same "web-types" linked in all subfolders that have a package.json. As well as in the root node. Otherwise this wouldn't work. As we have multiple files, it's a bit struggling when a new file arrives...

@brainfoolong - could you please share some example project, so that I can better understand what's the problem and experiment with possible solutions?

@piotrtomiak I have prepared a super simple basic project with a root folder and submodules, each of which can (but not must) have a package.json. Control or changing package.json in submodules is not (always) possible

You have 2 test.html files, on have autocompletion for the expected web-types, one have not.

image

web-types-test.zip

Conclusion: The thing i would really prefer is some sort of explicit file convention, that is auto-detected as a web-types.json file. For that i don't have to manage or even create package.json files just for that reason.

@brainfoolong Thanks! I am looking at some new options to provide Web Types wihtout package.json to implement in 2024.2

@brainfoolong Thanks! I am looking at some new options to provide Web Types wihtout package.json to implement in 2024.2

That sounds great, if i am finally able to kick all unnecessary package.json only existing for web-types :)

Hey @piotrtomiak - Can we see a preview of some new options in the PhpStorm 2024.2 EAP program? Don't find a trace for that in the release notes.

Just wanted to +1 on this, I'm also using htmx and shoelace in my project (which is a super simple app using ktor with server side rendering). I'm including htmx and shoelace in my index.html using <script ... tag and I don't use any build tools. The only way to add autocomplete support is to create package.json file with only one line "web-types": "./web-types.json"

@brainfoolong - I had in plans to add this support, but I have spent 3 months on implementing new solution for type checking in Angular. It was hell. I am going for vacations for few weeks. I want to add the support for 2024.3 and maybe we could cherrypick it to 2024.2.x.