question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Could the create command be separated into two commands, one for app and one for lib?

See original GitHub issue

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I’m always frustrated when […]

No.

Describe the idea you’d like A clear and concise description of what you want to happen.

I would like to see nx g @nxrocks/nx-flutter:create <app-folder> separated into:

nx g @nxrocks/nx-flutter:app <app-name> [–directory=<directory-name>] nx g @nxrocks/nx-flutter:lib <lib-name> [–directory=<directory-name>]

; and allowing them to be integrated into the nx dependecy graph mechanism. Flutter has applications, modules, packages, and plugins, so there is a natural separation between apps and libs as far as the flutter cli is concerned.

Describe alternatives you’ve considered A clear and concise description of any alternative solutions or features you’ve considered.

The scaffolding schema could be easily split into two schemas, one for app and one for lib. Since you are defering to the flutter cli in both cases it should as easy as changing the schematic’s schema and allowing only for certain cli arguments in each case. This line:

const projectType = ProjectType.Application;

should become:

const projectType = ProjectType.Library;

in the library case.

Additional context Add any other context or screenshots about the feature request here.

There is of course the issue of imports. I think to fully appreciate the nx tool for code sharing, you ought to be able to import a flutter lib in a flutter app. But because nx is a node.js tool I am also thinking there would have to be some integration with the dart language to be able to excute npm build or npm test at the root directory and have your flutter app pull it’s dependencies and compile. This is just an idea, since I think nx + flutter would be a really cool setup for a web, mobile, desktop, AND node.js backend and run the whole show from 1 repo.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jameswspearscommented, Feb 14, 2021

Hi @tinesoft,

I like the idea of making the existing comand smarter, rather than splitting 1 command into 2 commands. What you describe is definately a better approach.

I have given some thought about how you would integrate with dep-graph (note: this insight comes from using the nx tool and so is basically my assumptions about how nx works, not from analysis of the code, and is specific to my experience which is nx with TypeScript/Angular).

So, for the imports, the nx tool is making use of the TypeScript compiler’s path mapping feature. So if you were to do something similar with Flutter, I think I would start looking at the Dart compiler and seeing if there were any similar features, like mapped imports, with which you could integrate with nx via a node package (I am thinking something like the node equivalent of a polyfill).

With dep-graph it seems to me nx is aware of the TypeScript mapped imports, and the user defined project structure (apps, libs and tools) then by analyzing the code and the tsconfig is able to construct the dep graph using the mapped imports. I have also noticed implicit dependencies are noted in the root level nx.json, but other user defined dependencies (ex. importing a lib into an app) are not present. So the logic of dep-graph must be something like: recurse directories of all the apps, libs, and tools, look for mapped imports, and construct the graph, then add implicit dependencies from nx.json.

SO, it would be ideal if nx would allow you to add dependencies to the nx.json (maybe this already exists) to support cross language projects. And it was was easy as amending the nx.json to alter the dep-graph. The nx algorithm could still do it’s thing and look for mapped imports, and then in step where it is looking for “implicitDependencies”, also look for “explicitDependencies”, and add those in last.

I was a bit hesitant to make this request, because as I wrote I started to realize that there was only so much you could do as a plugin, you kind of have to play by the existing rules. But I think the ideal plugin would allow you to create 2 apps and 1 lib and let both apps import the lib. If this is not possible, then perhaps after some more research this can become a feature request to Nx for better multi-language support, or to Dart for mapped imports. I also need to do more research. Thanks for sharing your plugin though, very cool, much appreciated.

0reactions
github-actions[bot]commented, Apr 2, 2021

🎉 This issue has been resolved in version @nxrocks/nx-flutter-v2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I split my Click commands, each with a set of sub ...
In cli.py , I've written a add_subcommand() function that loops through every filepath globbed by "subcommands/*.py" and then does the import and add...
Read more >
Chaining Commands in Linux - GeeksforGeeks
Chaining commands in Linux allows us to execute multiple commands at the same time and directly through the terminal.
Read more >
Create an app with multiple stacks - AWS Documentation
Stacks are the unit of deployment: each stack in an app can be ... Next, create an AWS CDK project by entering the...
Read more >
Commanding Overview - WPF .NET Framework
Commands have several purposes. The first purpose is to separate the semantics and the object that invokes a command from the logic that ......
Read more >
Best practices for writing Dockerfiles - Docker Documentation
CMD specifies what command to run within the container. When you run an image and generate a container, you add a new writable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found