importmap-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +49 -0
- data/Rakefile +19 -0
- data/app/assets/javascripts/es-module-shims.js +1 -0
- data/app/assets/javascripts/es-module-shims@0.12.2.js +633 -0
- data/app/helpers/importmap/importmap_tags_helper.rb +26 -0
- data/lib/importmap-rails.rb +5 -0
- data/lib/importmap/engine.rb +22 -0
- data/lib/importmap/paths.rb +56 -0
- data/lib/importmap/version.rb +3 -0
- data/lib/install/install.rb +37 -0
- data/lib/shim.js +1 -0
- data/lib/tasks/importmap_tasks.rake +6 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58fefa79a892e0017e46e2b1b1f6298e16938ddce9f947e9570bb5e01b6f92ce
|
4
|
+
data.tar.gz: f86494f7134a6bfb2263709e1ee672b295a8211707c46458819707e2252c5315
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c18ac3eea56dd8ede9b26ef69ded67a7ced18a16870a9c666d4dd78c7307883e494961c7ea9fa5425671bfa1ae1e52def91ed1dbb14135ef2c310643bb06cad3
|
7
|
+
data.tar.gz: 949b018e0ad949d018dbec735d265eda311271d2ffaaf389263b28609c63dc6c2da154bd9f9694783008e3bc2aea310239e3a0b2b4632b0185c9159b8f8460a8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2021 Basecamp
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Importmap for Rails
|
2
|
+
|
3
|
+
[Import maps](https://github.com/WICG/import-maps) let you import JavaScript modules using logical names that map to versioned/digested files – directly from the browser. So you can build modern JavaScript applications using JavaScript libraries made for ESM without the need for transpiling or bundling. Without the need for such preprocessing, you can build advanced Rails applications without Webpack, Yarn, NPM, or any other part of the JavaScript toolchain. All you need is the asset pipeline that's already included in Rails.
|
4
|
+
|
5
|
+
With this approach you'll ship many small JavaScript files instead of one big JavaScript file. Thanks to HTTP2 that no longer carries a material performance penalty during the initial transport, and in fact offers substantial benefits over the long run due to better caching dynamics. Whereas before, any change to any JavaScript file included in your big bundle would invalidate the cache for the the whole bundle, now only the cache for that single file is invalidated.
|
6
|
+
|
7
|
+
There's [native support for import maps in Chrome/Edge 89+](https://caniuse.com/?search=importmap), and [a shim available](https://github.com/guybedford/es-module-shims) for any browser with basic ESM support. So your app will be able to work with all the evergreen browsers.
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
1. Add `importmap-rails` to your Gemfile with `gem 'importmap-rails'` (make sure it's included before any gems using it!)
|
13
|
+
2. Run `./bin/bundle install`
|
14
|
+
3. Run `./bin/rails importmap:install`
|
15
|
+
|
16
|
+
By default, all the files in `app/assets/javascripts` and the three major Rails JavaScript libraries are already mapped. You can add more mappings in `config/initializers/assets.rb`.
|
17
|
+
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
The import map is configured programmatically through the `Rails.application.config.importmap.paths` assignment, which by default is setup in `config/initializers/assets.rb` after running the installer. (Note that since this is a config initializer, you must restart your development server after making any changes.)
|
22
|
+
|
23
|
+
This programmatically configured import map is inlined in the `<head>` of your application layout using `<%= javascript_importmap_tags %>`, which will setup the JSON configuration inside a `<script type="importmap">` tag. After that, the [es-module-shim](https://github.com/guybedford/es-module-shims) is loaded, and then finally the application entrypoint is imported via `<script type="module">import "application"</script>`. That logical entrypoint, `application`, is mapped in the importmap script tag to the file `app/assets/javascripts/application.js`, which is copied and digested by the asset pipeline.
|
24
|
+
|
25
|
+
It's in `app/assets/javascripts/application.js` you setup your application by importing any of the modules that have been defined in the import map. You can use the full ESM functionality of importing any particular export of the modules or everything.
|
26
|
+
|
27
|
+
It makes sense to use logical names that match the package names used by NPM, such that if you later want to start transpiling or bundling your code, you'll not have to change any module imports.
|
28
|
+
|
29
|
+
|
30
|
+
## Use with Hotwire
|
31
|
+
|
32
|
+
This gem was designed for use with [Hotwire](https://hotwired.dev) in mind. The Hotwire gems, like [turbo-rails](https://github.com/hotwired/turbo-rails) and [stimulus-rails](https://github.com/hotwired/stimulus-rails) (both bundled as [hotwire-rails](https://github.com/hotwired/hotwire-rails)), are automatically configured for use with `importmap-rails`. This means you won't have to manually setup the path mapping in `config/initializers/assets.rb`, and instead can simply refer to the logical names directly in your `app/assets/javascripts/application.js`, like so:
|
33
|
+
|
34
|
+
```js
|
35
|
+
import "@hotwired/turbo-rails"
|
36
|
+
import "@hotwired/stimulus-autoloader"
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
## Expected errors from using the es-module-shim
|
41
|
+
|
42
|
+
While import maps are native in Chrome and Edge, they need a shim in other browsers that'll produce a JavaScript console error like `TypeError: Module specifier, 'application' does not start with "/", "./", or "../".`. This error is normal and does not have any user-facing consequences.
|
43
|
+
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
Importmap for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
|
48
|
+
|
49
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
|
3
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
4
|
+
load "rails/tasks/engine.rake"
|
5
|
+
|
6
|
+
load "rails/tasks/statistics.rake"
|
7
|
+
|
8
|
+
require "bundler/gem_tasks"
|
9
|
+
|
10
|
+
require "rake/testtask"
|
11
|
+
|
12
|
+
Rake::TestTask.new(:test) do |t|
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = false
|
16
|
+
t.warning = false
|
17
|
+
end
|
18
|
+
|
19
|
+
task default: :test
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ./es-module-shims@0.12.2.js
|
@@ -0,0 +1,633 @@
|
|
1
|
+
/* ES Module Shims 0.12.2 */
|
2
|
+
(function () {
|
3
|
+
const resolvedPromise = Promise.resolve();
|
4
|
+
|
5
|
+
let baseUrl;
|
6
|
+
|
7
|
+
function createBlob (source, type = 'text/javascript') {
|
8
|
+
return URL.createObjectURL(new Blob([source], { type }));
|
9
|
+
}
|
10
|
+
|
11
|
+
const hasDocument = typeof document !== 'undefined';
|
12
|
+
|
13
|
+
// support browsers without dynamic import support (eg Firefox 6x)
|
14
|
+
let supportsDynamicImport = false;
|
15
|
+
let supportsJsonAssertions = false;
|
16
|
+
let dynamicImport;
|
17
|
+
try {
|
18
|
+
dynamicImport = (0, eval)('u=>import(u)');
|
19
|
+
supportsDynamicImport = true;
|
20
|
+
}
|
21
|
+
catch (e) {
|
22
|
+
if (hasDocument) {
|
23
|
+
let err;
|
24
|
+
self.addEventListener('error', e => err = e.error);
|
25
|
+
dynamicImport = blobUrl => {
|
26
|
+
const topLevelBlobUrl = createBlob(
|
27
|
+
`import*as m from'${blobUrl}';self._esmsi=m;`
|
28
|
+
);
|
29
|
+
const s = document.createElement('script');
|
30
|
+
s.type = 'module';
|
31
|
+
s.src = topLevelBlobUrl;
|
32
|
+
document.head.appendChild(s);
|
33
|
+
return new Promise((resolve, reject) => {
|
34
|
+
s.addEventListener('load', () => {
|
35
|
+
document.head.removeChild(s);
|
36
|
+
if (self._esmsi) {
|
37
|
+
resolve(self._esmsi, baseUrl);
|
38
|
+
self._esmsi = null;
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
reject(err);
|
42
|
+
}
|
43
|
+
});
|
44
|
+
});
|
45
|
+
};
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
let supportsImportMeta = false;
|
50
|
+
let supportsImportMaps = false;
|
51
|
+
|
52
|
+
const featureDetectionPromise = Promise.all([
|
53
|
+
dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, () => {}),
|
54
|
+
dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, () => {}),
|
55
|
+
supportsDynamicImport && hasDocument && new Promise(resolve => {
|
56
|
+
self._$s = v => {
|
57
|
+
document.body.removeChild(iframe);
|
58
|
+
if (v) supportsImportMaps = true;
|
59
|
+
delete self._$s;
|
60
|
+
resolve();
|
61
|
+
};
|
62
|
+
const iframe = document.createElement('iframe');
|
63
|
+
iframe.style.display = 'none';
|
64
|
+
iframe.srcdoc = `<script type=importmap>{"imports":{"x":"data:text/javascript,"}}<${''}/script><script>import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`, 'text/html';
|
65
|
+
document.body.appendChild(iframe);
|
66
|
+
})
|
67
|
+
]);
|
68
|
+
|
69
|
+
if (hasDocument) {
|
70
|
+
const baseEl = document.querySelector('base[href]');
|
71
|
+
if (baseEl)
|
72
|
+
baseUrl = baseEl.href;
|
73
|
+
}
|
74
|
+
|
75
|
+
if (!baseUrl && typeof location !== 'undefined') {
|
76
|
+
baseUrl = location.href.split('#')[0].split('?')[0];
|
77
|
+
const lastSepIndex = baseUrl.lastIndexOf('/');
|
78
|
+
if (lastSepIndex !== -1)
|
79
|
+
baseUrl = baseUrl.slice(0, lastSepIndex + 1);
|
80
|
+
}
|
81
|
+
|
82
|
+
const backslashRegEx = /\\/g;
|
83
|
+
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
84
|
+
// strip off any trailing query params or hashes
|
85
|
+
parentUrl = parentUrl && parentUrl.split('#')[0].split('?')[0];
|
86
|
+
if (relUrl.indexOf('\\') !== -1)
|
87
|
+
relUrl = relUrl.replace(backslashRegEx, '/');
|
88
|
+
// protocol-relative
|
89
|
+
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
90
|
+
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
91
|
+
}
|
92
|
+
// relative-url
|
93
|
+
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
|
94
|
+
relUrl.length === 1 && (relUrl += '/')) ||
|
95
|
+
relUrl[0] === '/') {
|
96
|
+
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
97
|
+
// Disabled, but these cases will give inconsistent results for deep backtracking
|
98
|
+
//if (parentUrl[parentProtocol.length] !== '/')
|
99
|
+
// throw new Error('Cannot resolve');
|
100
|
+
// read pathname from parent URL
|
101
|
+
// pathname taken to be part after leading "/"
|
102
|
+
let pathname;
|
103
|
+
if (parentUrl[parentProtocol.length + 1] === '/') {
|
104
|
+
// resolving to a :// so we need to read out the auth and host
|
105
|
+
if (parentProtocol !== 'file:') {
|
106
|
+
pathname = parentUrl.slice(parentProtocol.length + 2);
|
107
|
+
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
pathname = parentUrl.slice(8);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
// resolving to :/ so pathname is the /... part
|
115
|
+
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
116
|
+
}
|
117
|
+
|
118
|
+
if (relUrl[0] === '/')
|
119
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
120
|
+
|
121
|
+
// join together and split for removal of .. and . segments
|
122
|
+
// looping the string instead of anything fancy for perf reasons
|
123
|
+
// '../../../../../z' resolved to 'x/y' is just 'z'
|
124
|
+
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
125
|
+
|
126
|
+
const output = [];
|
127
|
+
let segmentIndex = -1;
|
128
|
+
for (let i = 0; i < segmented.length; i++) {
|
129
|
+
// busy reading a segment - only terminate on '/'
|
130
|
+
if (segmentIndex !== -1) {
|
131
|
+
if (segmented[i] === '/') {
|
132
|
+
output.push(segmented.slice(segmentIndex, i + 1));
|
133
|
+
segmentIndex = -1;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
// new segment - check if it is relative
|
138
|
+
else if (segmented[i] === '.') {
|
139
|
+
// ../ segment
|
140
|
+
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
141
|
+
output.pop();
|
142
|
+
i += 2;
|
143
|
+
}
|
144
|
+
// ./ segment
|
145
|
+
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
146
|
+
i += 1;
|
147
|
+
}
|
148
|
+
else {
|
149
|
+
// the start of a new segment as below
|
150
|
+
segmentIndex = i;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
// it is the start of a new segment
|
154
|
+
else {
|
155
|
+
segmentIndex = i;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
// finish reading out the last segment
|
159
|
+
if (segmentIndex !== -1)
|
160
|
+
output.push(segmented.slice(segmentIndex));
|
161
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
/*
|
166
|
+
* Import maps implementation
|
167
|
+
*
|
168
|
+
* To make lookups fast we pre-resolve the entire import map
|
169
|
+
* and then match based on backtracked hash lookups
|
170
|
+
*
|
171
|
+
*/
|
172
|
+
function resolveUrl (relUrl, parentUrl) {
|
173
|
+
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (relUrl.indexOf(':') !== -1 ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
174
|
+
}
|
175
|
+
|
176
|
+
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
177
|
+
for (let p in packages) {
|
178
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
179
|
+
let target = packages[p];
|
180
|
+
if (typeof target !== 'string')
|
181
|
+
continue;
|
182
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
183
|
+
if (mapped) {
|
184
|
+
outPackages[resolvedLhs] = mapped;
|
185
|
+
continue;
|
186
|
+
}
|
187
|
+
targetWarning(p, packages[p], 'bare specifier did not resolve');
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
function resolveAndComposeImportMap (json, baseUrl, parentMap) {
|
192
|
+
const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
|
193
|
+
|
194
|
+
if (json.imports)
|
195
|
+
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
196
|
+
|
197
|
+
if (json.scopes)
|
198
|
+
for (let s in json.scopes) {
|
199
|
+
const resolvedScope = resolveUrl(s, baseUrl);
|
200
|
+
resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
|
201
|
+
}
|
202
|
+
|
203
|
+
return outMap;
|
204
|
+
}
|
205
|
+
|
206
|
+
function getMatch (path, matchObj) {
|
207
|
+
if (matchObj[path])
|
208
|
+
return path;
|
209
|
+
let sepIndex = path.length;
|
210
|
+
do {
|
211
|
+
const segment = path.slice(0, sepIndex + 1);
|
212
|
+
if (segment in matchObj)
|
213
|
+
return segment;
|
214
|
+
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
|
215
|
+
}
|
216
|
+
|
217
|
+
function applyPackages (id, packages) {
|
218
|
+
const pkgName = getMatch(id, packages);
|
219
|
+
if (pkgName) {
|
220
|
+
const pkg = packages[pkgName];
|
221
|
+
if (pkg === null) return;
|
222
|
+
if (id.length > pkgName.length && pkg[pkg.length - 1] !== '/')
|
223
|
+
targetWarning(pkgName, pkg, "should have a trailing '/'");
|
224
|
+
else
|
225
|
+
return pkg + id.slice(pkgName.length);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
function targetWarning (match, target, msg) {
|
230
|
+
console.warn("Package target " + msg + ", resolving target '" + target + "' for " + match);
|
231
|
+
}
|
232
|
+
|
233
|
+
function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
|
234
|
+
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
235
|
+
while (scopeUrl) {
|
236
|
+
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
237
|
+
if (packageResolution)
|
238
|
+
return packageResolution;
|
239
|
+
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
240
|
+
}
|
241
|
+
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
242
|
+
}
|
243
|
+
|
244
|
+
/* es-module-lexer 0.7.1 */
|
245
|
+
const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then(()=>parse(E));const I=E.length+1,D=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;D>0&&C.memory.grow(Math.ceil(D/65536));const w=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,w,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const L=[],k=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),D=C.se();let w;C.ip()&&(w=o(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),L.push({n:w,s:A,e:Q,ss:I,se:D,d:g,a:B});}for(;C.re();)k.push(E.slice(C.es(),C.ee()));function o(A){try{return (0,eval)(A)}catch{}}return [L,k,!!C.f()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const init=WebAssembly.compile((E="AGFzbQEAAAABXA1gAX8Bf2AEf39/fwBgAn9/AGAAAX9gAABgAX8AYAZ/f39/f38Bf2AEf39/fwF/YAN/f38Bf2AHf39/f39/fwF/YAV/f39/fwF/YAJ/fwF/YAh/f39/f39/fwF/AzIxAAECAwMDAwMDAwMDAwMDAwAEBQAGBAQAAAAABAQEBAQABgcICQoLDAACAAAACwMJDAQFAXABAQEFAwEAAQYPAn8BQfDwAAt/AEHw8AALB2QRBm1lbW9yeQIAAnNhAAABZQADAmlzAAQCaWUABQJzcwAGAnNlAAcCYWkACAJpZAAJAmlwAAoCZXMACwJlZQAMAnJpAA0CcmUADgFmAA8FcGFyc2UAEAtfX2hlYXBfYmFzZQMBCrc6MWgBAX9BACAANgK4CEEAKAKQCCIBIABBAXRqIgBBADsBAEEAIABBAmoiADYCvAhBACAANgLACEEAQQA2ApQIQQBBADYCpAhBAEEANgKcCEEAQQA2ApgIQQBBADYCrAhBAEEANgKgCCABC7IBAQJ/QQAoAqQIIgRBHGpBlAggBBtBACgCwAgiBTYCAEEAIAU2AqQIQQAgBDYCqAhBACAFQSBqNgLAC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0EAKAKkCCIBIAI2AhAgAUEAKALkCEECajYCDAswAQF/AkACQCAAQXdqIgFBF0sNAEEBIAF0QY2AgARxDQELIABBoAFGDQBBAA8LQQELbQECfwJAAkADQAJAIABB//8DcSIBQXdqIgJBF0sNAEEBIAJ0QZ+AgARxDQILIAFBoAFGDQEgACECIAEQLA0CQQAhAkEAQQAoAuQIIgBBAmo2AuQIIAAvAQIiAA0ADAILCyAAIQILIAJB//8DcQtoAQJ/QQEhAQJAAkAgAEFfaiICQQVLDQBBASACdEExcQ0BCyAAQfj/A3FBKEYNACAAQUZqQf//A3FBBkkNAAJAIABBpX9qIgJBA0sNACACQQFHDQELIABBhX9qQf//A3FBBEkhAQsgAQtgAQJ/AkBBACgC5AgiAi8BACIDQeEARw0AQQAgAkEEajYC5AhBARAoIQJBACgC5AghACACECsaQQAoAuQIIQFBARAoIQNBACgC5AghAgsCQCACIABGDQAgACABEAILIAMLiQEBBX9BACgC5AghAEEAKALoCCEBA38gAEECaiECAkACQCAAIAFPDQAgAi8BACIDQaR/aiIEQQFNDQEgAiEAIANBdmoiA0EDSw0CIAIhACADDgQAAgIAAAtBACACNgLkCBAfQQAPCwJAAkAgBA4CAQABC0EAIAI2AuQIQd0ADwsgAEEEaiEADAALC0kBAX9BACEHAkAgAC8BCiAGRw0AIAAvAQggBUcNACAALwEGIARHDQAgAC8BBCADRw0AIAAvAQIgAkcNACAALwEAIAFGIQcLIAcLUwEBf0EAIQgCQCAALwEMIAdHDQAgAC8BCiAGRw0AIAAvAQggBUcNACAALwEGIARHDQAgAC8BBCADRw0AIAAvAQIgAkcNACAALwEAIAFGIQgLIAgLCx8CAEGACAsCAAAAQYQICxABAAAAAgAAAAAEAABwOAAA","undefined"!=typeof Buffer?Buffer.from(E,"base64"):Uint8Array.from(atob(E),A=>A.charCodeAt(0)))).then(WebAssembly.instantiate).then(({exports:A})=>{C=A;});var E;
|
246
|
+
|
247
|
+
let id = 0;
|
248
|
+
const registry = {};
|
249
|
+
if (self.ESMS_DEBUG) {
|
250
|
+
self._esmsr = registry;
|
251
|
+
}
|
252
|
+
|
253
|
+
async function loadAll (load, seen) {
|
254
|
+
if (load.b || seen[load.u])
|
255
|
+
return;
|
256
|
+
seen[load.u] = 1;
|
257
|
+
await load.L;
|
258
|
+
await Promise.all(load.d.map(dep => loadAll(dep, seen)));
|
259
|
+
if (!load.n)
|
260
|
+
load.n = load.d.some(dep => dep.n);
|
261
|
+
}
|
262
|
+
|
263
|
+
let waitingForImportMapsInterval;
|
264
|
+
let firstTopLevelProcess = true;
|
265
|
+
async function topLevelLoad (url, fetchOpts, source, nativelyLoaded) {
|
266
|
+
// no need to even fetch if we have feature support
|
267
|
+
await featureDetectionPromise;
|
268
|
+
if (waitingForImportMapsInterval > 0) {
|
269
|
+
clearTimeout(waitingForImportMapsInterval);
|
270
|
+
waitingForImportMapsInterval = 0;
|
271
|
+
}
|
272
|
+
if (firstTopLevelProcess) {
|
273
|
+
firstTopLevelProcess = false;
|
274
|
+
processScripts();
|
275
|
+
}
|
276
|
+
await importMapPromise;
|
277
|
+
// early analysis opt-out
|
278
|
+
if (nativelyLoaded && supportsDynamicImport && supportsImportMeta && supportsImportMaps && !importMapSrcOrLazy) {
|
279
|
+
// dont reexec inline for polyfills -> just return null
|
280
|
+
return source && nativelyLoaded ? null : dynamicImport(source ? createBlob(source) : url);
|
281
|
+
}
|
282
|
+
await init;
|
283
|
+
const load = getOrCreateLoad(url, fetchOpts, source);
|
284
|
+
const seen = {};
|
285
|
+
await loadAll(load, seen);
|
286
|
+
lastLoad = undefined;
|
287
|
+
resolveDeps(load, seen);
|
288
|
+
if (source && !nativelyLoaded && !shimMode && !load.n) {
|
289
|
+
const module = dynamicImport(createBlob(source));
|
290
|
+
if (shouldRevokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
291
|
+
return module;
|
292
|
+
}
|
293
|
+
const module = await dynamicImport(load.b);
|
294
|
+
// if the top-level load is a shell, run its update function
|
295
|
+
if (load.s) {
|
296
|
+
(await dynamicImport(load.s)).u$_(module);
|
297
|
+
}
|
298
|
+
if (shouldRevokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
299
|
+
return module;
|
300
|
+
}
|
301
|
+
|
302
|
+
function revokeObjectURLs(registryKeys) {
|
303
|
+
let batch = 0;
|
304
|
+
const keysLength = registryKeys.length;
|
305
|
+
const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
|
306
|
+
schedule(cleanup);
|
307
|
+
function cleanup() {
|
308
|
+
const batchStartIndex = batch * 100;
|
309
|
+
if (batchStartIndex > keysLength) return
|
310
|
+
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
311
|
+
const load = registry[key];
|
312
|
+
if (load) URL.revokeObjectURL(load.b);
|
313
|
+
}
|
314
|
+
batch++;
|
315
|
+
schedule(cleanup);
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
async function importShim (id, parentUrl = baseUrl, _assertion) {
|
320
|
+
await featureDetectionPromise;
|
321
|
+
// Make sure all the "in-flight" import maps are loaded and applied.
|
322
|
+
await importMapPromise;
|
323
|
+
return topLevelLoad(resolve(id, parentUrl).r || throwUnresolved(id, parentUrl), { credentials: 'same-origin' });
|
324
|
+
}
|
325
|
+
|
326
|
+
self.importShim = importShim;
|
327
|
+
|
328
|
+
const meta = {};
|
329
|
+
|
330
|
+
const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
|
331
|
+
|
332
|
+
async function importMetaResolve (id, parentUrl = this.url) {
|
333
|
+
await importMapPromise;
|
334
|
+
return resolve(id, `${parentUrl}`).r || throwUnresolved(id, parentUrl);
|
335
|
+
}
|
336
|
+
|
337
|
+
self._esmsm = meta;
|
338
|
+
|
339
|
+
const esmsInitOptions = self.esmsInitOptions || {};
|
340
|
+
delete self.esmsInitOptions;
|
341
|
+
let shimMode = typeof esmsInitOptions.shimMode === 'boolean' ? esmsInitOptions.shimMode : !!esmsInitOptions.fetch || !!document.querySelector('script[type="module-shim"],script[type="importmap-shim"]');
|
342
|
+
const fetchHook = esmsInitOptions.fetch || ((url, opts) => fetch(url, opts));
|
343
|
+
const skip = esmsInitOptions.skip || /^https?:\/\/(cdn\.skypack\.dev|jspm\.dev)\//;
|
344
|
+
const onerror = esmsInitOptions.onerror || ((e) => { throw e; });
|
345
|
+
const shouldRevokeBlobURLs = esmsInitOptions.revokeBlobURLs;
|
346
|
+
|
347
|
+
function urlJsString (url) {
|
348
|
+
return `'${url.replace(/'/g, "\\'")}'`;
|
349
|
+
}
|
350
|
+
|
351
|
+
let lastLoad;
|
352
|
+
function resolveDeps (load, seen) {
|
353
|
+
if (load.b || !seen[load.u])
|
354
|
+
return;
|
355
|
+
seen[load.u] = 0;
|
356
|
+
|
357
|
+
for (const dep of load.d)
|
358
|
+
resolveDeps(dep, seen);
|
359
|
+
|
360
|
+
// use direct native execution when possible
|
361
|
+
// load.n is therefore conservative
|
362
|
+
if (!shimMode && !load.n) {
|
363
|
+
load.b = lastLoad = load.u;
|
364
|
+
load.S = undefined;
|
365
|
+
return;
|
366
|
+
}
|
367
|
+
|
368
|
+
const [imports] = load.a;
|
369
|
+
|
370
|
+
// "execution"
|
371
|
+
const source = load.S;
|
372
|
+
|
373
|
+
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
|
374
|
+
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
375
|
+
|
376
|
+
if (!imports.length) {
|
377
|
+
resolvedSource += source;
|
378
|
+
}
|
379
|
+
else {
|
380
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
381
|
+
// and define this blob
|
382
|
+
let lastIndex = 0, depIndex = 0;
|
383
|
+
for (const { s: start, se: end, d: dynamicImportIndex } of imports) {
|
384
|
+
// dependency source replacements
|
385
|
+
if (dynamicImportIndex === -1) {
|
386
|
+
const depLoad = load.d[depIndex++];
|
387
|
+
let blobUrl = depLoad.b;
|
388
|
+
if (!blobUrl) {
|
389
|
+
// circular shell creation
|
390
|
+
if (!(blobUrl = depLoad.s)) {
|
391
|
+
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
392
|
+
depLoad.a[1].map(
|
393
|
+
name => name === 'default' ? `$_default=m.default` : `${name}=m.${name}`
|
394
|
+
).join(',')
|
395
|
+
}}${
|
396
|
+
depLoad.a[1].map(name =>
|
397
|
+
name === 'default' ? `let $_default;export{$_default as default}` : `export let ${name}`
|
398
|
+
).join(';')
|
399
|
+
}\n//# sourceURL=${depLoad.r}?cycle`);
|
400
|
+
}
|
401
|
+
}
|
402
|
+
// circular shell execution
|
403
|
+
else if (depLoad.s) {
|
404
|
+
resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)};import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
405
|
+
lastIndex = end;
|
406
|
+
depLoad.s = undefined;
|
407
|
+
continue;
|
408
|
+
}
|
409
|
+
resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)}`;
|
410
|
+
lastIndex = end;
|
411
|
+
}
|
412
|
+
// import.meta
|
413
|
+
else if (dynamicImportIndex === -2) {
|
414
|
+
meta[load.r] = { url: load.r, resolve: importMetaResolve };
|
415
|
+
resolvedSource += `${source.slice(lastIndex, start)}self._esmsm[${urlJsString(load.r)}]`;
|
416
|
+
lastIndex = end;
|
417
|
+
}
|
418
|
+
// dynamic import
|
419
|
+
else {
|
420
|
+
resolvedSource += `${source.slice(lastIndex, dynamicImportIndex + 6)}Shim(${source.slice(start, end)}, ${load.r && urlJsString(load.r)}`;
|
421
|
+
lastIndex = end;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
|
425
|
+
resolvedSource += source.slice(lastIndex);
|
426
|
+
}
|
427
|
+
|
428
|
+
resolvedSource = resolvedSource.replace(/\/\/# sourceMappingURL=(.*)\s*$/, (match, url) => {
|
429
|
+
return match.replace(url, new URL(url, load.r));
|
430
|
+
});
|
431
|
+
let hasSourceURL = false;
|
432
|
+
resolvedSource = resolvedSource.replace(/\/\/# sourceURL=(.*)\s*$/, (match, url) => {
|
433
|
+
hasSourceURL = true;
|
434
|
+
return match.replace(url, new URL(url, load.r));
|
435
|
+
});
|
436
|
+
if (!hasSourceURL) {
|
437
|
+
resolvedSource += '\n//# sourceURL=' + load.r;
|
438
|
+
}
|
439
|
+
|
440
|
+
load.b = lastLoad = createBlob(resolvedSource);
|
441
|
+
load.S = undefined;
|
442
|
+
}
|
443
|
+
|
444
|
+
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
445
|
+
const jsonContentType = /^application\/json(;|$)/;
|
446
|
+
const cssContentType = /^text\/css(;|$)/;
|
447
|
+
const wasmContentType = /^application\/wasm(;|$)/;
|
448
|
+
|
449
|
+
const fetchOptsMap = new Map();
|
450
|
+
|
451
|
+
function getOrCreateLoad (url, fetchOpts, source) {
|
452
|
+
let load = registry[url];
|
453
|
+
if (load)
|
454
|
+
return load;
|
455
|
+
|
456
|
+
load = registry[url] = {
|
457
|
+
// url
|
458
|
+
u: url,
|
459
|
+
// response url
|
460
|
+
r: undefined,
|
461
|
+
// fetchPromise
|
462
|
+
f: undefined,
|
463
|
+
// source
|
464
|
+
S: undefined,
|
465
|
+
// linkPromise
|
466
|
+
L: undefined,
|
467
|
+
// analysis
|
468
|
+
a: undefined,
|
469
|
+
// deps
|
470
|
+
d: undefined,
|
471
|
+
// blobUrl
|
472
|
+
b: undefined,
|
473
|
+
// shellUrl
|
474
|
+
s: undefined,
|
475
|
+
// needsShim
|
476
|
+
n: false
|
477
|
+
};
|
478
|
+
|
479
|
+
load.f = (async () => {
|
480
|
+
if (!source) {
|
481
|
+
// preload fetch options override fetch options (race)
|
482
|
+
const res = await fetchHook(url, fetchOptsMap.get(url) || fetchOpts);
|
483
|
+
if (!res.ok)
|
484
|
+
throw new Error(`${res.status} ${res.statusText} ${res.url}`);
|
485
|
+
load.r = res.url;
|
486
|
+
const contentType = res.headers.get('content-type');
|
487
|
+
if (jsContentType.test(contentType))
|
488
|
+
source = await res.text();
|
489
|
+
else if (jsonContentType.test(contentType))
|
490
|
+
source = `export default ${await res.text()}`;
|
491
|
+
else if (cssContentType.test(contentType))
|
492
|
+
throw new Error('CSS modules not yet supported');
|
493
|
+
else if (wasmContentType.test(contentType))
|
494
|
+
throw new Error('WASM modules not yet supported');
|
495
|
+
else
|
496
|
+
throw new Error(`Unknown Content-Type "${contentType}"`);
|
497
|
+
}
|
498
|
+
try {
|
499
|
+
load.a = parse(source, load.u);
|
500
|
+
}
|
501
|
+
catch (e) {
|
502
|
+
console.warn(e);
|
503
|
+
load.a = [[], []];
|
504
|
+
}
|
505
|
+
load.S = source;
|
506
|
+
return load;
|
507
|
+
})();
|
508
|
+
|
509
|
+
load.L = load.f.then(async () => {
|
510
|
+
let childFetchOpts = fetchOpts;
|
511
|
+
load.d = await Promise.all(load.a[0].map(({ n, d, a }) => {
|
512
|
+
if (d >= 0 && !supportsDynamicImport ||
|
513
|
+
d === 2 && (!supportsImportMeta || source.slice(end, end + 8) === '.resolve') ||
|
514
|
+
a && !supportsJsonAssertions)
|
515
|
+
load.n = true;
|
516
|
+
if (!n) return;
|
517
|
+
const { r, m } = resolve(n, load.r || load.u);
|
518
|
+
if (m && (!supportsImportMaps || importMapSrcOrLazy))
|
519
|
+
load.n = true;
|
520
|
+
if (d !== -1) return;
|
521
|
+
if (!r)
|
522
|
+
throwUnresolved(n, load.r || load.u);
|
523
|
+
if (skip.test(r)) return { b: r };
|
524
|
+
if (childFetchOpts.integrity)
|
525
|
+
childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
526
|
+
return getOrCreateLoad(r, childFetchOpts).f;
|
527
|
+
}).filter(l => l));
|
528
|
+
});
|
529
|
+
|
530
|
+
return load;
|
531
|
+
}
|
532
|
+
|
533
|
+
let importMap = { imports: {}, scopes: {} };
|
534
|
+
let importMapSrcOrLazy = false;
|
535
|
+
let importMapPromise = resolvedPromise;
|
536
|
+
|
537
|
+
if (hasDocument) {
|
538
|
+
processScripts();
|
539
|
+
waitingForImportMapsInterval = setInterval(processScripts, 20);
|
540
|
+
}
|
541
|
+
|
542
|
+
async function processScripts () {
|
543
|
+
if (waitingForImportMapsInterval > 0 && document.readyState !== 'loading') {
|
544
|
+
clearTimeout(waitingForImportMapsInterval);
|
545
|
+
waitingForImportMapsInterval = 0;
|
546
|
+
}
|
547
|
+
for (const link of document.querySelectorAll('link[rel="modulepreload"]'))
|
548
|
+
processPreload(link);
|
549
|
+
for (const script of document.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]'))
|
550
|
+
await processScript(script);
|
551
|
+
}
|
552
|
+
|
553
|
+
new MutationObserver(mutations => {
|
554
|
+
for (const mutation of mutations) {
|
555
|
+
if (mutation.type !== 'childList') continue;
|
556
|
+
for (const node of mutation.addedNodes) {
|
557
|
+
if (node.tagName === 'SCRIPT' && node.type)
|
558
|
+
processScript(node, !firstTopLevelProcess);
|
559
|
+
else if (node.tagName === 'LINK' && node.rel === 'modulepreload')
|
560
|
+
processPreload(node);
|
561
|
+
else if (node.querySelectorAll) {
|
562
|
+
for (const script of node.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"],script[type="module"],script[type="importmap"]')) {
|
563
|
+
processScript(script, !firstTopLevelProcess);
|
564
|
+
}
|
565
|
+
for (const link of node.querySelectorAll('link[rel=modulepreload]')) {
|
566
|
+
processPreload(link);
|
567
|
+
}
|
568
|
+
}
|
569
|
+
}
|
570
|
+
}
|
571
|
+
}).observe(document, { childList: true, subtree: true });
|
572
|
+
|
573
|
+
function getFetchOpts (script) {
|
574
|
+
const fetchOpts = {};
|
575
|
+
if (script.integrity)
|
576
|
+
fetchOpts.integrity = script.integrity;
|
577
|
+
if (script.referrerpolicy)
|
578
|
+
fetchOpts.referrerPolicy = script.referrerpolicy;
|
579
|
+
if (script.crossorigin === 'use-credentials')
|
580
|
+
fetchOpts.credentials = 'include';
|
581
|
+
else if (script.crossorigin === 'anonymous')
|
582
|
+
fetchOpts.credentials = 'omit';
|
583
|
+
else
|
584
|
+
fetchOpts.credentials = 'same-origin';
|
585
|
+
return fetchOpts;
|
586
|
+
}
|
587
|
+
|
588
|
+
async function processScript (script, dynamic) {
|
589
|
+
if (script.ep) // ep marker = script processed
|
590
|
+
return;
|
591
|
+
const shim = script.type.endsWith('-shim');
|
592
|
+
if (shim) shimMode = true;
|
593
|
+
const type = shim ? script.type.slice(0, -5) : script.type;
|
594
|
+
if (!shim && shimMode || script.getAttribute('noshim') !== null)
|
595
|
+
return;
|
596
|
+
// empty inline scripts sometimes show before domready
|
597
|
+
if (!script.src && !script.innerHTML)
|
598
|
+
return;
|
599
|
+
script.ep = true;
|
600
|
+
if (type === 'module') {
|
601
|
+
await topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shim).catch(onerror);
|
602
|
+
}
|
603
|
+
else if (type === 'importmap') {
|
604
|
+
importMapPromise = importMapPromise.then(async () => {
|
605
|
+
if (script.src || dynamic)
|
606
|
+
importMapSrcOrLazy = true;
|
607
|
+
importMap = resolveAndComposeImportMap(script.src ? await (await fetchHook(script.src)).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
|
608
|
+
});
|
609
|
+
}
|
610
|
+
}
|
611
|
+
|
612
|
+
function processPreload (link) {
|
613
|
+
if (link.ep) // ep marker = processed
|
614
|
+
return;
|
615
|
+
link.ep = true;
|
616
|
+
// prepopulate the load record
|
617
|
+
const fetchOpts = getFetchOpts(link);
|
618
|
+
// save preloaded fetch options for later load
|
619
|
+
fetchOptsMap.set(link.href, fetchOpts);
|
620
|
+
fetch(link.href, fetchOpts);
|
621
|
+
}
|
622
|
+
|
623
|
+
function resolve (id, parentUrl) {
|
624
|
+
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
|
625
|
+
const resolved = resolveImportMap(importMap, urlResolved || id, parentUrl);
|
626
|
+
return { r: resolved, m: urlResolved !== resolved };
|
627
|
+
}
|
628
|
+
|
629
|
+
function throwUnresolved (id, parentUrl) {
|
630
|
+
throw Error("Unable to resolve specifier '" + id + (parentUrl ? "' from " + parentUrl : "'"));
|
631
|
+
}
|
632
|
+
|
633
|
+
}());
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Importmap::ImportmapTagsHelper
|
2
|
+
# Setup all script tags needed to use an importmap-powered entrypoint (which defaults to application.js)
|
3
|
+
def javascript_importmap_tags(entry_point = "application")
|
4
|
+
safe_join [
|
5
|
+
javascript_inline_importmap_tag,
|
6
|
+
javascript_importmap_shim_tag,
|
7
|
+
javascript_import_module_tag(entry_point)
|
8
|
+
], "\n"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Generate an inline importmap tag using the passed `importmap_paths` object to produce the JSON map.
|
12
|
+
# By default, `Rails.application.config.importmap.paths` is used for this object,
|
13
|
+
def javascript_inline_importmap_tag(importmap_paths = Rails.application.config.importmap.paths)
|
14
|
+
tag.script(importmap_paths.to_json(self).html_safe, type: "importmap")
|
15
|
+
end
|
16
|
+
|
17
|
+
# Include the es-module-shim needed to make importmaps work in browsers without native support (like Firefox + Safari).
|
18
|
+
def javascript_importmap_shim_tag
|
19
|
+
javascript_include_tag "es-module-shims", async: true
|
20
|
+
end
|
21
|
+
|
22
|
+
# Import a named JavaScript module using a script-module tag.
|
23
|
+
def javascript_import_module_tag(module_name)
|
24
|
+
tag.script %(import "#{module_name}").html_safe, type: "module"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "importmap/paths"
|
2
|
+
|
3
|
+
module Importmap
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
config.importmap = ActiveSupport::OrderedOptions.new
|
6
|
+
config.importmap.paths = Importmap::Paths.new.tap { |paths| paths.assets_in "app/assets/javascripts" }
|
7
|
+
|
8
|
+
config.autoload_once_paths = %W( #{root}/app/helpers )
|
9
|
+
|
10
|
+
initializer "importmap.assets" do
|
11
|
+
if Rails.application.config.respond_to?(:assets)
|
12
|
+
Rails.application.config.assets.precompile += %w( es-module-shims )
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer "importmap.helpers" do
|
17
|
+
ActiveSupport.on_load(:action_controller_base) do
|
18
|
+
helper Importmap::ImportmapTagsHelper
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class Importmap::Paths
|
2
|
+
attr_reader :files, :directories
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@files = {}
|
6
|
+
@directories = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def asset(name, path: nil)
|
10
|
+
@files[name] = path || "#{name}.js"
|
11
|
+
end
|
12
|
+
|
13
|
+
def assets_in(path, append_base_path: false)
|
14
|
+
@directories[path] = append_base_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_json(resolver)
|
18
|
+
{ "imports" => map_to_asset_paths(resolver) }.to_json
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def map_to_asset_paths(resolver)
|
23
|
+
expanded_files_and_directories.transform_values { |path| resolver.asset_path(path) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def expanded_files_and_directories
|
27
|
+
@files.dup.tap { |expanded| expand_directories_into expanded }
|
28
|
+
end
|
29
|
+
|
30
|
+
def expand_directories_into(paths)
|
31
|
+
@directories.each do |(path, append_base_path)|
|
32
|
+
if (absolute_path = absolute_root_of(path)).exist?
|
33
|
+
find_javascript_files_in_tree(absolute_path).each do |filename|
|
34
|
+
module_filename = filename.relative_path_from(absolute_path)
|
35
|
+
module_name = module_name_from(module_filename)
|
36
|
+
module_path = append_base_path ? absolute_path.basename.join(module_filename).to_s : module_filename.to_s
|
37
|
+
|
38
|
+
paths[module_name] = module_path
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Strip off the extension, /index, or any versioning data for an absolute module name.
|
45
|
+
def module_name_from(filename)
|
46
|
+
filename.to_s.remove(filename.extname).remove("/index").split("@").first
|
47
|
+
end
|
48
|
+
|
49
|
+
def find_javascript_files_in_tree(path)
|
50
|
+
Dir[path.join("**/*.js{,m}")].collect { |file| Pathname.new(file) }.select(&:file?)
|
51
|
+
end
|
52
|
+
|
53
|
+
def absolute_root_of(path)
|
54
|
+
(pathname = Pathname.new(path)).absolute? ? pathname : Rails.root.join(path)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
2
|
+
|
3
|
+
if APPLICATION_LAYOUT_PATH.exist?
|
4
|
+
say "Add Importmap include tags in application layout"
|
5
|
+
insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= javascript_importmap_tags %>", before: /\s*<\/head>/
|
6
|
+
else
|
7
|
+
say "Default application.html.erb is missing!", :red
|
8
|
+
say " Add <%= javascript_importmap_tags %> within the <head> tag in your custom layout."
|
9
|
+
end
|
10
|
+
|
11
|
+
say "Create application.js module as entrypoint"
|
12
|
+
create_file Rails.root.join("app/assets/javascripts/application.js") do <<-JS
|
13
|
+
// import "@rails/actioncable"
|
14
|
+
// import "@rails/actiontext"
|
15
|
+
// import "@rails/activestorage"
|
16
|
+
JS
|
17
|
+
end
|
18
|
+
|
19
|
+
say "Ensure JavaScript files are in the asset pipeline manifest"
|
20
|
+
append_to_file Rails.root.join("app/assets/config/manifest.js"), %(//= link_tree ../javascripts)
|
21
|
+
|
22
|
+
say "Configure importmap paths in config/initializers/assets.rb"
|
23
|
+
append_to_file Rails.root.join("config/initializers/assets.rb") do <<-RUBY
|
24
|
+
|
25
|
+
# Configure importmap paths in addition to having all files in app/assets/javascripts mapped.
|
26
|
+
Rails.application.config.importmap.paths do |paths|
|
27
|
+
# Match libraries with their NPM package names for possibility of easy later porting.
|
28
|
+
# Ensure that libraries listed in the path have been linked in the asset pipeline manifest or precompiled.
|
29
|
+
paths.asset "@rails/actioncable", path: "actioncable.esm.js"
|
30
|
+
paths.asset "@rails/actiontext", path: "actiontext.js"
|
31
|
+
paths.asset "@rails/activestorage", path: "activestorage.esm.js"
|
32
|
+
|
33
|
+
# Make all files in directory available as my_channel => channels/my_channel-$digest.js
|
34
|
+
# paths.assets_in "lib/assets/javascripts/channels", append_base_path: true
|
35
|
+
end
|
36
|
+
RUBY
|
37
|
+
end
|
data/lib/shim.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
import "es-module-shim"
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: importmap-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Heinemeier Hansson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
description:
|
28
|
+
email: david@loudthinking.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- MIT-LICENSE
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- app/assets/javascripts/es-module-shims.js
|
37
|
+
- app/assets/javascripts/es-module-shims@0.12.2.js
|
38
|
+
- app/helpers/importmap/importmap_tags_helper.rb
|
39
|
+
- lib/importmap-rails.rb
|
40
|
+
- lib/importmap/engine.rb
|
41
|
+
- lib/importmap/paths.rb
|
42
|
+
- lib/importmap/version.rb
|
43
|
+
- lib/install/install.rb
|
44
|
+
- lib/shim.js
|
45
|
+
- lib/tasks/importmap_tasks.rake
|
46
|
+
homepage: https://github.com/rails/importmap-rails
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata:
|
50
|
+
homepage_uri: https://github.com/rails/importmap-rails
|
51
|
+
source_code_uri: https://github.com/rails/importmap-rails
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubygems_version: 3.1.4
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: Use ESM with importmap to manage modern JavaScript in Rails without transpiling
|
71
|
+
or bundling.
|
72
|
+
test_files: []
|