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

package:web migration page #5524

Merged
merged 11 commits into from
Feb 15, 2024
2 changes: 1 addition & 1 deletion examples/create_libraries/lib/hw_mp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ library hw_mp;
// #docregion export
export 'src/hw_none.dart' // Stub implementation
if (dart.library.io) 'src/hw_io.dart' // dart:io implementation
if (dart.library.html) 'src/hw_html.dart'; // dart:html implementation
if (dart.library.js_interop) 'src/hw_web.dart'; // package:web implementation
2 changes: 1 addition & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
{ "source": "/go/null-safety-migration", "destination": "/null-safety/migration-guide", "type": 301 },
{ "source": "/go/package-discontinue", "destination": "/tools/pub/publishing#discontinue", "type": 301 },
{ "source": "/go/package-retraction", "destination": "/tools/pub/publishing#retract", "type": 301 },
{ "source": "/go/package-web", "destination": "https://pub.dev/packages/web", "type": 301 },
{ "source": "/go/package-web", "destination": "/interop/js-interop/package-web", "type": 301 },
{ "source": "/go/pub-cache", "destination": "/tools/pub/cmd/pub-cache", "type": 301 },
{ "source": "/go/pubignore", "destination": "/tools/pub/publishing#what-files-are-published", "type": 301 },
{ "source": "/go/publishing-from-github", "destination": "/tools/pub/automated-publishing#publishing-packages-using-github-actions", "type": 301 },
Expand Down
2 changes: 1 addition & 1 deletion src/_data/side-nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
permalink: /interop/js-interop/past-js-interop
- divider
- title: Web interop
permalink: /interop/js-interop/dom
permalink: /interop/js-interop/package-web

- title: Tools & techniques
expanded: false
Expand Down
10 changes: 5 additions & 5 deletions src/content/guides/libraries/create-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ by importing a single file.

The lib directory might also include other importable, non-src, libraries.
For example, perhaps your main library works across platforms, but
you create separate libraries that rely on `dart:io` or `dart:html`.
you create separate libraries that rely on `dart:io` or `dart:js_interop`.
Some packages have separate libraries that are meant to be imported
with a prefix, when the main library is not.

Expand Down Expand Up @@ -151,23 +151,23 @@ A common use case is a library that supports both web and native platforms.
To conditionally import or export,
you need to check for the presence of `dart:*` libraries.
Here's an example of conditional export code that
checks for the presence of `dart:io` and `dart:html`:
checks for the presence of `dart:io` and `dart:js_interop`:

<?code-excerpt "create_libraries/lib/hw_mp.dart (export)"?>
```dart title="lib/hw_mp.dart"
export 'src/hw_none.dart' // Stub implementation
if (dart.library.io) 'src/hw_io.dart' // dart:io implementation
if (dart.library.html) 'src/hw_html.dart'; // dart:html implementation
if (dart.library.js_interop) 'src/hw_web.dart'; // package:web implementation
```

Here's what that code does:

* In an app that can use `dart:io`
(for example, a command-line app),
export `src/hw_io.dart`.
* In an app that can use `dart:html`
* In an app that can use `dart:js_interop`
(a web app),
export `src/hw_html.dart`.
export `src/hw_web.dart`.
* Otherwise, export `src/hw_none.dart`.

To conditionally import a file, use the same code as above,
Expand Down
34 changes: 0 additions & 34 deletions src/content/interop/js-interop/dom.md

This file was deleted.

Loading