importmap-rails 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +21 -0
 - data/lib/importmap/map.rb +1 -1
 - data/lib/importmap/npm.rb +2 -2
 - data/lib/importmap/version.rb +1 -1
 - data/lib/importmap-rails.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4aeaabf5f2e5ff22f899b925176126c59d50f0160fc380b2614ba90ef187b077
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7b2a751caf4d3e8a6669fbef2ca9165b5a25681240cb4656e1a24094628e9ff2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1010224d71e6d9e7d9f4a4da395fd025b87a7c765be93917afb5160cc7a6f2aa25829c4cbad98b49ea2d6b813c5770acff76172dd200fa520219f2e44e80bb8b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 54c230bb6c7fefeb91f1b84cba05d826c3883a29dfeba49b4e0cbd68253e68cd16acd59240a3a481bd09e75605b44c6fd7664deae4163b5e26dcd1bcb6de1a80
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -63,6 +63,27 @@ It's in `app/javascript/application.js` you setup your application by importing 
     | 
|
| 
       63 
63 
     | 
    
         | 
| 
       64 
64 
     | 
    
         
             
            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 won't have to change any module imports.
         
     | 
| 
       65 
65 
     | 
    
         | 
| 
      
 66 
     | 
    
         
            +
            ### Local modules
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            If you want to import local js module files from `app/javascript/src` or other sub-folders of `app/javascript` (such as `channels`), you must pin these to be able to import them.
         
     | 
| 
      
 69 
     | 
    
         
            +
            You can use `pin_all_from` to pick all files in a specific folder, so you don't have to `pin` each module individually.
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            ```rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            # config/importmap.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            pin_all_from 'app/javascript/src`, under: 'src', to: 'src'
         
     | 
| 
      
 74 
     | 
    
         
            +
            ```
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            The `:to` parameter is only required if you want to change the destination logical import name. If you drop the :to option, you must place the :under option directly after the first parameter.
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            Allows you to:
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            ```js
         
     | 
| 
      
 81 
     | 
    
         
            +
            // app/javascript/application.js
         
     | 
| 
      
 82 
     | 
    
         
            +
            import { ExampleFunction } from 'src/example_function'
         
     | 
| 
      
 83 
     | 
    
         
            +
            ```
         
     | 
| 
      
 84 
     | 
    
         
            +
            Which imports the function from `app/javascript/src/example_function.js`.
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            Note: Sprockets used to serve assets (albeit without filename digests) it couldn't find from the `app/javascripts` folder with logical relative paths, meaning pinning local files wasn't needed. Propshaft doesn't have this fallback, so when you use Propshaft you have to pin your local modules.
         
     | 
| 
       66 
87 
     | 
    
         | 
| 
       67 
88 
     | 
    
         
             
            ## Using npm packages via JavaScript CDNs
         
     | 
| 
       68 
89 
     | 
    
         | 
    
        data/lib/importmap/map.rb
    CHANGED
    
    | 
         @@ -145,7 +145,7 @@ class Importmap::Map 
     | 
|
| 
       145 
145 
     | 
    
         
             
                end
         
     | 
| 
       146 
146 
     | 
    
         | 
| 
       147 
147 
     | 
    
         
             
                def module_path_from(filename, mapping)
         
     | 
| 
       148 
     | 
    
         
            -
                  [ mapping.path || mapping.under, filename.to_s ].compact.join("/")
         
     | 
| 
      
 148 
     | 
    
         
            +
                  [ mapping.path || mapping.under, filename.to_s ].compact.reject(&:empty?).join("/")
         
     | 
| 
       149 
149 
     | 
    
         
             
                end
         
     | 
| 
       150 
150 
     | 
    
         | 
| 
       151 
151 
     | 
    
         
             
                def find_javascript_files_in_tree(path)
         
     | 
    
        data/lib/importmap/npm.rb
    CHANGED
    
    | 
         @@ -48,8 +48,8 @@ class Importmap::Npm 
     | 
|
| 
       48 
48 
     | 
    
         
             
                # We cannot use the name after "pin" because some dependencies are loaded from inside packages
         
     | 
| 
       49 
49 
     | 
    
         
             
                # Eg. pin "buffer", to: "https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.19/nodelibs/browser/buffer.js"
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                importmap.scan(/^pin .*(?<=npm:|npm\/|skypack\.dev\/|unpkg\.com\/)(.*)(?=@\d+\.\d+\.\d+)@(\d+\.\d+\.\d+(?:[^\/\s"]*)).*$/) |
         
     | 
| 
       52 
     | 
    
         
            -
                  importmap.scan(/^pin "([^"]*)".* #.*@(\d+\.\d+\.\d+(?:[^\s]*)).*$/)
         
     | 
| 
      
 51 
     | 
    
         
            +
                importmap.scan(/^pin .*(?<=npm:|npm\/|skypack\.dev\/|unpkg\.com\/)(.*)(?=@\d+\.\d+\.\d+)@(\d+\.\d+\.\d+(?:[^\/\s["']]*)).*$/) |
         
     | 
| 
      
 52 
     | 
    
         
            +
                  importmap.scan(/^pin ["']([^["']]*)["'].* #.*@(\d+\.\d+\.\d+(?:[^\s]*)).*$/)
         
     | 
| 
       53 
53 
     | 
    
         
             
              end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
              private
         
     | 
    
        data/lib/importmap/version.rb
    CHANGED
    
    
    
        data/lib/importmap-rails.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: importmap-rails
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - David Heinemeier Hansson
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-10-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: railties
         
     |