Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document how to write HTML imports #20076

Closed
sigmundch opened this issue Jul 16, 2014 · 5 comments
Closed

document how to write HTML imports #20076

sigmundch opened this issue Jul 16, 2014 · 5 comments
Assignees
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@sigmundch
Copy link
Member

This question comes up a bunch of times. It would be great to have documentation explaining why and how it works.

The main issue is that if you have a file under:

  package:a
    lib/a/b/c/d.html

and you want to import

  package:b
    lib/e/f.html

Then you need to write:
    href="../../../../../packages/e/f.html"

There are many cases that are slightly confusing that would be good to highlight in the docs:
 - from web to lib (even in the same package): packages/pname/f.html
 - from web/foo to lib: ../packages/pname/f.html
 - from lib to lib: ../../packages/pname/f.html
 - from lib/foo to lib: ../../../packages/pname/f.html

We should also highlight how this works and why we do it. Here are some of the details:
  - it needs to work in Dartium without any code transformation: resolving the path in the context of a simple-http-server should yield a valid path to the files. For now we can only assume that we can use a packages/ directory that is in web/packages

  - it needs to be canonicalizable: we might need to fix this further, but right now we do a lot of effort to make sure that if you have

      <link rel=import href=packages/a/a.html>
      and a.html has <script src=a.dart>
      and the entrypoint also loads "package:a/a.dart"

  Then both versions of a.dart are loaded from the same URL.

  We can only do this kind of canolicalization if we convert packages/a/a.dart into package:a/a.dart under the hood. We do so by detecting the package-pattern in the html-import urls.

  - it needs to continue to be valid after we compile the application. We could normalize the imports in our transformations, but given all the other restrictions we have above, we just keep them as they are.

@kwalrath
Copy link
Contributor

Set owner to @kwalrath.
Added this to the 1.6 milestone.
Removed Priority-Unassigned, Docs-Articles labels.
Added Priority-High, Docs-Polymer, Accepted labels.

@sigmundch
Copy link
Member Author

You probably have seen these, but just in case, there are a few threads in web@dartlang.org explaining this in more detail.

Here is a recent one: https://groups.google.com/a/dartlang.org/d/msgid/web/29e352df-fd25-4988-9a8a-02dd3b051346%40dartlang.org?utm_medium=email&utm_source=footer

@sigmundch
Copy link
Member Author

I just realized another detail that we should state clearly:

For files under web/ test/ or example/, you need to refer to the 'packages/' folder relative to your entrypoint file.

This can be really confusing. Here is an example:

  • entrypoint is web/a.html
  • a.html imports b/c.html
  • c.html has a package import as: ../packages/pname/d.html

however, here is how it can get confusing:

  • entrypoint is web/b/e.html
  • e.html imports f.html
  • f.html would have a package import as: packages/pname/d.html

If you need a file from 2 entrypoints, where both entrypoints are in different directories, then you need to move that file to the lib/ folder.

In general, I'd encourage people to use the lib/ folder more, since in that case the packages folder is always determined in isolation without having to know were the entrypoint is. For anything in lib, the number of ../ is the depth of the file within the package + 1.

@kwalrath
Copy link
Contributor

I want to fix this ASAP, but it might not happen for 1.6 and certainly shouldn't delay the release.


Removed this from the 1.6 milestone.
Added this to the 1.7 milestone.

@nicolasgarnier
Copy link
Contributor

This issue has been moved to Github as part of a migration. Please use the Issue on Github going forward: https://github.com/dart-lang/dartlang.org/issues


Added MovedToGithub label.

@sigmundch sigmundch added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures labels Aug 26, 2014
@sigmundch sigmundch added this to the 1.7 milestone Aug 26, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

3 participants