Skip to content
Snippets Groups Projects
Commit a03b623e authored by Ken Quiño's avatar Ken Quiño Committed by Pierre Rudloff
Browse files

Issue #3449305 by prudloff, sunil jolapara: README.md missing

parent a48f7841
No related branches found
No related tags found
1 merge request!33449305: Added README file.
Pipeline #456250 passed
......@@ -23,7 +23,5 @@ include:
# https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml
# Uncomment the lines below if you want to override any of the variables. The following is just an example.
################
# variables:
# SKIP_ESLINT: '1'
# OPT_IN_TEST_NEXT_MAJOR: '1'
# _CURL_TEMPLATES_REF: 'main'
variables:
_CSPELL_WORDS: 'gaël, gaëlg, gosset, prudloff, rudloff'
# Import map
This module allows you to add an import map to your website. It can be used to
enable JS imports without requiring the full path to the JS file.
For a full description of the module, visit the
[project page](https://www.drupal.org/project/importmap).
Submit bug reports and feature suggestions, or track changes in the
[issue queue](https://www.drupal.org/project/issues/importmap).
## Requirements
This module requires no modules outside of Drupal core.
## Installation
Install as you would normally install a contributed Drupal module. For further
information, see
[Installing Drupal Modules](https://www.drupal.org/docs/extending-drupal/installing-drupal-modules).
## Configuration
The module has no menu or modifiable settings. There is no configuration.
## Usage Example
For example, if you have this in your `libraries.yml` file:
```yaml
foo:
js:
js/foo.js: { attributes: { data-importmap-name: 'foo' } }
```
It will generate this import map:
```html
<script type="importmap">
{"imports":{"foo":"\/modules\/custom\/foo\/js\/foo.js?s3pik6"}}
</script>
```
And you can then use `import { foo } from "foo";` in your JS to import this file.
(Note that JS scripts that use `import` need to have the `type="module"` attribute.)
You do not have to attach libraries that are in the import map, they will be
downloaded automatically by the browser when using import.
## Preloading modules
You can also preload JS modules like this:
```yaml
foo:
js:
js/foo.js: { attributes: { data-importmap-name: 'foo', data-importmap-preload: true } }
```
This will make the browser preload the JS module so it can already be available
when executing the `import`.
## Maintainers
- Pierre Rudloff - [prudloff](https://www.drupal.org/u/prudloff)
- Gaël Gosset - [gaëlg](https://www.drupal.org/u/gaëlg)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment