This question comes in two parts. The first can be summed up by Public Image Limited, "This is what you want / This is what you get."
I'll keep the question simple by pointing to the tutorial:
- Define a Custom Element Dart tutorial
I 'decided' that I'd like to treat different elements as project assets (so to speak). So I made a sub-folder: named: components, that sits below the $/web/ folder, per:
Something like this:
enchilada/
:
web/
index.html
main.dart
style.css
components/
tut_stopwatch.html
tut_stopwatch.dart
When I did this: the Dart Editor becomes very confused. So firstly, I need to specify "what I want" and then describe, "What I get" [got]
I want:
- Dart to let me put sub-modules in subordinate folders.
- In this case custom elements like "tut_stopwatch", with appropriate adjustments for path changes (which I did).
- Ideally, I'd prefer if Dart could integrate subordinate modules at multiple levels.
- You might consider a custom UI element like a 'panel' that is a 'container' for several nested sub-components.
I get:
- A slew of compilation errors. These errors cycle: they "resolve" and later "reappear".
- I closed Dart Editor [1.2.0-release], Dart SDK [1.2.0] and restarted -- The problem persists.
- The 'error' centres on polymer, viz.:
Target of URI does not exist: 'package:../polymer/polymer.dart' Annotation can be only constant variable or constant constructor invocation Classes can only extend other classes Annotation can be only constant variable or constant constructor invocation
- I think not finding 'polymer' is a symptom. Dart Editor cycles: find <-> not_find
The cause of this behaviour appears to be me having moved the two files:
- tute_stopwatch.html, and
- tute_stopwatch.dart ...
Into the [sub-]components/ folder as shown (above). The error stems from the import for polymer in the file:
- components/tute_stopwatch.dart
Code as follows (Dart build errors as comments):
import 'package:polymer/polymer.dart';
@CustomTag('tute-stopwatch') // <-- Target of URI does not exist: 'package:polymer/polymer.dart'
class TuteStopwatch extends PolymerElement { // <-- Annotation can be only constant variable or constant constructor invocation
@observable String counter='00:00'; // <-- Classes can only extend other classes
// Undefined class 'PolymerElement'
TuteStopwatch.created() : super.created();
:
} // TutStopwatch class
One thing to point-out is that the Dart Editor makes a Windows Junction link to the packages/ folder in every sub-folder. That would be a symlink on Linux or Mac. So the packages file path should function OK.
I'm looking for a strategy to get what I want? To have sub-folders for different modules or 'features' with Dart and Dart Editor in development? Thanks in advance ... /w
v02 ... Added code for import polymer error.
v01 ... Original query.