Parcel: Multiple extension support

Created on 6 Jun 2018  ยท  3Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ™‹ feature request

Multiple extension support (e.g tar.gz)

๐Ÿค” Expected Behavior

Resolve asset with full extension

๐Ÿ˜ฏ Current Behavior

Resolve asset with part of extension (e.g .gz)

๐Ÿ’ Possible Solution

Split extension from the first dot.
https://github.com/parcel-bundler/parcel/blob/24f28bc5d7dd4324841209379d2823654ab9c8e7/src/Parser.js#L69

๐Ÿ”ฆ Context

Create plugin with multiple dots extensions, or just load tar.gz file.

๐Ÿ’ป Examples

import download from './compress.tar.gz';

Help Wanted Feature โœจ Parcel 2

Most helpful comment

Going to close this since it is solved in Parcel 2 where plugins are matched using globs. You could use something like *.tar.gz

All 3 comments

I found a regex which might be helping: https://regex101.com/r/nQ4oW8/1
/(?:\.ext[1-4])+$/i

found here: https://stackoverflow.com/a/21607977/3793309

This requires a set of predefined extensions, but it's the most straightforward approach I could think of right now.

I wouldn't split after first dot, since this could bring new issues, e.g. a plugin which has files like myPlugin.v1.1.js or like your example: import download from './compress.tar.gz'; <= .tar.gz

The actual extracting of the extension will be fairly hard as a filename is allowed to contain dots that are not part of any extension, I propose the following:

Regex out extensions
=> Search known extensions
  => Match? => Use specified Asset
  => No Match? => Use last extension
        => Match? => Use specified Asset
        => No Match? => Fallback to RawAsset

Going to close this since it is solved in Parcel 2 where plugins are matched using globs. You could use something like *.tar.gz

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipodev picture philipodev  ยท  3Comments

mnn picture mnn  ยท  3Comments

urbanhop picture urbanhop  ยท  3Comments

medhatdawoud picture medhatdawoud  ยท  3Comments

Niggler picture Niggler  ยท  3Comments