Skip to content
  • Ross Kaffenberger's avatar
    5603b0aa
    Ensure missing entry error message includes asset file type (#2426) · 5603b0aa
    Ross Kaffenberger authored
    Webpack view helpers that indicate pack type in the method name, e.g.
    javascript_pack_tag, stylesheet_pack_tag, support manifest lookup both
    with or without the extname in the given file name. For example, given
    an existing pack for application.js, all of the following manifest
    lookups will succeed:
    
    ```
    javascript_pack_tag "application"    # or
    javascript_pack_tag "application.js"
    
    stylesheet_pack_tag "application"    # or
    stylesheet_pack_tag "application.css"
    ```
    
    When the lookup does not succeed, a helpful error message is displayed.
    However, if the ".js" extension is omitted from the helper method
    invocation, the error message also omits the pack type. For example:
    
    ```
    javascript_pack_tag "not-a-pack"
    stylesheet_pack_tag "not-a-pack"
    ```
    results in the following error message:
    
    ```
    Webpacker can't find not-a-pack in
    /path/to/app/public/packs/manifest.json
    ```
    
    The ambiguity is confusing when using `extract_css` true: does this
    indicate the server was looking for the javascript bundle or the
    stylesheet?
    
    This changeset resolves the ambiguity by leveraging the existing support
    in the manifest for determining the qualified pack name by passing type
    to the method that handles the missing entry info.
    
    Also, adds some assertions and extracts a couple shared methods in
    manifest_test.rb
    5603b0aa
    Ensure missing entry error message includes asset file type (#2426)
    Ross Kaffenberger authored
    Webpack view helpers that indicate pack type in the method name, e.g.
    javascript_pack_tag, stylesheet_pack_tag, support manifest lookup both
    with or without the extname in the given file name. For example, given
    an existing pack for application.js, all of the following manifest
    lookups will succeed:
    
    ```
    javascript_pack_tag "application"    # or
    javascript_pack_tag "application.js"
    
    stylesheet_pack_tag "application"    # or
    stylesheet_pack_tag "application.css"
    ```
    
    When the lookup does not succeed, a helpful error message is displayed.
    However, if the ".js" extension is omitted from the helper method
    invocation, the error message also omits the pack type. For example:
    
    ```
    javascript_pack_tag "not-a-pack"
    stylesheet_pack_tag "not-a-pack"
    ```
    results in the following error message:
    
    ```
    Webpacker can't find not-a-pack in
    /path/to/app/public/packs/manifest.json
    ```
    
    The ambiguity is confusing when using `extract_css` true: does this
    indicate the server was looking for the javascript bundle or the
    stylesheet?
    
    This changeset resolves the ambiguity by leveraging the existing support
    in the manifest for determining the qualified pack name by passing type
    to the method that handles the missing entry info.
    
    Also, adds some assertions and extracts a couple shared methods in
    manifest_test.rb
Loading