langium icon indicating copy to clipboard operation
langium copied to clipboard

generator-langium: Transform generated project to npm workspace

Open kaisalmen opened this issue 1 year ago • 17 comments

TODO:

  • [x] Align template structure with target structure
  • [x] Integrate a global tsconfig.build.json in target project
  • [x] Unify how build and compile is done in target project
  • [x] Update to the latest version of the wrapper lib stack
  • [x] Fix Build issues: Create index files and export code to other packages
  • [x] Fix regular generator-langium unit tests
  • [x] Add new test that check the complete structure
  • [x] Option test not yet included even if selected
  • [x] tsconfig.build.json needs to be dynamically created. Sources not contained should not be included as it leads to build failures otherwise.
  • [x] Align dependencies and update vitest
  • [x] Remove the need to use http-server

Fixes #1495

TODO: from review:

  • [x] Update langium-quickstart.md
  • [x] Add clean script and build:clean to all packages

kaisalmen avatar May 29 '24 15:05 kaisalmen

@msujew @Yokozuna59 the generated workspace project builds again. Now, I need to fix the open points above ⬆️

kaisalmen avatar Jun 05 '24 06:06 kaisalmen

@msujew @Yokozuna59 this is now ready for review. The only thing left is from the list is removing the need for http-server in the web package, because vite preview should do the job. But this is not blocking the review.

kaisalmen avatar Jun 14 '24 09:06 kaisalmen

For me workspaces were hard to work with in the beginning, because I was switching to the packages folders to run npm run X. Would be good to have some documentation on our website, I think. Like workspace 101, especially with the -w flag to address packages. Does it change anything for the existing documentation?

Lotes avatar Jun 14 '24 09:06 Lotes

Does it change anything for the existing documentation?

Very likely 🙂 We need to update it once this is merged.

kaisalmen avatar Jun 14 '24 09:06 kaisalmen

Like workspace 101

The generated project is the blueprint. 👍 It features all facets: TS with specific test configs, VSCode eslint compatibility (root tsconfig.json per package), workspace eslint check, global build and top-level scripts that directly execute package scripts.

kaisalmen avatar Jun 14 '24 09:06 kaisalmen

All points are resolved. I also fix an issue with the web example. I broke the configuration during this update. It is working again.

kaisalmen avatar Jun 14 '24 11:06 kaisalmen

@Yokozuna59 thank you for the review. I still need to implement the two bigger points (added to the description) and then I am done. Any further enhancements should go to a next PR, because this one is already quite large, but there was no way around.

kaisalmen avatar Jun 16 '24 08:06 kaisalmen

@Yokozuna59 and @msujew all TODOs are done. We need to update tutorials and docs on the website as well. This change has some impact.

kaisalmen avatar Jun 19 '24 08:06 kaisalmen

I rebased the branch after Langium 3.1.0 release to resolve the conflicts.

kaisalmen avatar Jun 21 '24 11:06 kaisalmen

@msujew I just updated to the latest wrapper version. Do you have time to review it this week?

kaisalmen avatar Jul 02 '24 17:07 kaisalmen

@msujew rework is complete. Im have not closed some of the discussions, because you should check if you agree with my solutions.

kaisalmen avatar Jul 08 '24 08:07 kaisalmen

@kaisalmen I created a project from this branch and it seems there is an issue with the generated CLI. I think the following paths inside packages/generator-langium/templates/packages/cli should be updated:

  • In bin/cli.js, it should import from just '../out/main.js' (without /cli)
  • In src/main.ts:13, the packagePath should have one less '..'

At least that's what I edited manually in my project for it to work

aabounegm avatar Jul 08 '24 10:07 aabounegm

@aabounegm Thank you very much! Many things changed, it is easy to overlook things. I will push an update.

kaisalmen avatar Jul 08 '24 11:07 kaisalmen

any updates on this? Will this be part of a 3.2 release?

zeyad001 avatar Jul 18 '24 13:07 zeyad001

And one more thing: it seems that vsce does not currently support npm workspaces (https://github.com/microsoft/vscode-vsce/issues/777#issuecomment-1285089955), so running vsce package tries to bundle the entire project (with all workspaces) and fails with weird errors. Until this is fixed, there are 3 possible workarounds:

  1. Add ../ and ../../ to .vscodeignore
  2. Add "vsce": { "dependencies": false } to package.json
  3. Add a note that users need to pass --no-dependencies to the vsce command

I personally opted for the first option in my project with a comment linking to the issue.

And on a somewhat related note (also publishing), I would suggest adding a .gitignore file to packages/extension with at least *.vsix.

aabounegm avatar Jul 25 '24 12:07 aabounegm

We used solution 2 in our own extension, too: https://github.com/eclipse-langium/langium/blob/3b007c2be9a6ec0c93f4dac62eea33854909db60/packages/langium-vscode/package.json#L84-L86

spoenemann avatar Jul 26 '24 07:07 spoenemann

@aabounegm thank you for those additional findings/comments. Regarding vsce I selected option 2, modified the gitignore and fixed the prebublish/lint

kaisalmen avatar Aug 08 '24 13:08 kaisalmen

Superseded by #1810.

spoenemann avatar Apr 11 '25 14:04 spoenemann