Dart Plugin - Cannot Import a Dart Module from a folder!

The Dart plug-in for IntelliJ IDEA is unable to import a Dart Module in my Dart project from a folder.

If I select "Import Module.." from the File Menu, it doesn't show the *.yaml extension of a Dart module in the list of available files formats.
If I try to import any Dart Module from a folder, after selecting the .yaml file I get the following error: Cannot Import anything from /Users/.../.../pubspec.yaml

Schermata 2013-12-07 alle 14.17.23.png
Schermata 2013-12-07 alle 14.28.20.png

It is also impossible to import a Dart Project using the "Import Project..." option of the "File Menu", and selecting the Dart Project file (usually named: "pubspec.yaml").

The only way to load a Dart Module or a Dart Project from a disc folder is to create a new Dart project in IntelliJ IDE, edit the pubspec.yaml file and manually add a package source with the "path:" option.

For example, to add the module "Dart Web Toolkit" you need to edit the yaml file in this way:

name: untitled1
dependencies:
  browser: any
  dart_web_toolkit:
    path: /Users/Emanuele/Documents/DART Projects/Dart Web Toolkit

And then you need to select the "Dart Get Dependencies" option from the contextual menu to import it.
Also this method does not add a new module or a new project, but only add the module as a "dependency".
There is no way to directly import a Dart module and automatically create a new Dart Project with it.

Note that this is also true if the module or the project is not a local folder but it is hosted on a Git repository. There is no way to add a Dart module or a Dart project, you need to create a new project, and manually edit the yaml file adding the url to the dependencies section, like this:

name: untitled1
dependencies:
  browser: any
  dart_web_toolkit:
    git:
      url: git://github.com/akserg/dart_web_toolkit
      ref: master

Proposed Solution:

- Allow to import a Dart Module or a Dart Project from a folder, supporting the *.yaml file format in the "Import Module" or in the "Import Project" options of the File Menu
- Allow to import a Dart Module or a Dart Project from a Git repository url, adding a "Import Module from Git" and a "Import Project from Git" option in the File Menu
- Allow to add a Dart Module to an existing Dart project as a dependency selecting the correspondent *.yaml file from a folder or the Git repository url.

Thank you.

3 comments
Comment actions Permalink

Hi,

in IntelliJ IDEA terms you don't need to 'import' Dart module, you need to configure an IntelliJ IDEA project/module for existing sources. To do this:

  • to create a new project with one Dart module based on existing sources:
    • click File | New Project or Create New Project on the Welcome screen
    • on the list at the left side of the New Project dialog select Web (in the Static Web secion)
    • select existing folder (where pubspec.yaml and other stuff resists) as a Project location (the 2nd field at the right side of the dialog)
    • check project name (by default it will be equal to the folder name)
    • just to understand what's going to happen expand More Settings in the right-bottom corner and see what module will be added to the project
    • click Finish

  • if you already have some project configured and want to add a new Dart module to the project that will be based on existing sources then:
    • click File | New Module
    • on the list at the left side of the New Module dialog select Web (in the Static Web secion)
    • select existing folder (where pubspec.yaml and other stuff resists) as a Content root (the 2nd field at the right side of the dialog)
    • check module name (by default it will be equal to the folder name)
    • click Finish


I agree that it would be more convenient to click Import and select pubspec.yaml file or its parent folder and let IntelliJ IDEA do all the stuff automatically. Will handle it in scope of the issue that you submitted: http://youtrack.jetbrains.com/issue/WEB-10211

Note that integration with Git and other version control systems already allows you to checkout and configure the project. Start with Checkout from Version Control at the Welcome screen or VCS | Checkout from Version Control.

0
Comment actions Permalink

Thank you Alexander, but even following your instructions I was not able to import correctly a Dart project.

I followed this instructions for a simple project residing on a disc folder :

in IntelliJ IDEA terms you don't need to 'import' Dart module, you need to configure an IntelliJ IDEA project/module for existing sources. To do this:

  • to create a new project with one Dart module based on existing sources:
    • click File | New Project or Create New Project on the Welcome screen
    • on the list at the left side of the New Project dialog select Web (in the Static Web secion)
    • select existing folder (where pubspec.yaml and other stuff resists) as a Project location (the 2nd field at the right side of the dialog)
    • check project name (by default it will be equal to the folder name)
    • just to understand what's going to happen expand More Settings in the right-bottom corner and see what module will be added to the project
    • click Finish


But the project is imported without creating any configuration:

dart plugin bug 2013-12-09 alle 15.55.15.png

If I try to edit a new configuration, clicking on "Edit Configuration...", no default configuration option for "Dart Web Application" is found:

Dart plugin bug2 2013-12-09 alle 15.56.07.png

Solution:
- The Dart PlugIn must add a new Configuration called "Dart Web Application"
- When creating or importing an existing Dart Project, it should automatically use the project informations in the *.yaml file, like the "entry_points:" parameter, to create the correct launch configuration for Dart (i.e. launching Dartium and not Chrome browser).
- If more entry points are specified in the project *.yaml file "entry_points:" parameter, it should automatically create additionals launch configurations for each one.

Thank you.

0
Comment actions Permalink

To create a run configuration right click html file and select 'Create xxx.html' or 'Debug xxx.html'. Dart web apps are launched using run configurations of type 'JavaScript debug' that will be created. I agree, not ideal wording. By default it will be launched in Dartium.

0

Please sign in to leave a comment.