I'm testing my plugin to get inlined svgs instead of urls.

Below a screenshot of the build file:


Below a screenshot of the build file:

I'm asking for help people!
I guess the issue is with the asset ids...
This is kinda random...
Building and building again (eg. just changing the order of the requires) sometimes will not print the duplicate 4 (expected behaviour) but most of the times the requires will have that same numeric require (100% the number 4 in my example) hence the current behaviour.
Numbers in general are sequential but often not (I don't know much about that, could you address me somewhere in the code?)
I'd like to start fixing this but I'd like to have a hint from you. Where to start? Is it my plugin? No idea yet. The plugin itself is very basic so far. Nothing fancy really.
https://github.com/albinotonnina/parcel-plugin-inlinesvg/tree/master/example
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | any
| Node | > 8
| npm/Yarn | both :P
| Operating System | osx high sierra
Same happens with another plugin https://github.com/fansenze/parcel-plugin-url-loader by @fansenze


Does this still accure with latest master branch?
@DeMoorJasper afraid so!
I had the same on parcel-plugin-typescript (see #7). This is because two Asset.js are used, one from src and one from lib, it means that you'll get duplicated IDs. I did this as a workaround :
import JSAssetLib = require('parcel-bundler/lib/assets/JSAsset')
import JSAssetSrc = require('parcel-bundler/src/assets/JSAsset')
export const JSAsset = parseInt(process.versions.node, 10) < 8 ? JSAssetLib : JSAssetSrc
Related to #251 , the api needs some improvements to expose more internal functions in a proper way
Thanks @fathyb, it fixes for me too.
const JSAssetLib = require('parcel-bundler/lib/assets/JSAsset')
const JSAssetSrc = require('parcel-bundler/src/assets/JSAsset')
const JSAsset = parseInt(process.versions.node, 10) < 8 ? JSAssetLib : JSAssetSrc
Plugin fixed https://github.com/albinotonnina/parcel-plugin-inlinesvg
Ah, ideally plugins wouldn't extend the internal asset types at all. The API should be better about allowing composition of assets.
Closing due to inactivity and plugin api being rewritten in Parcel 2
Most helpful comment
Thanks @fathyb, it fixes for me too.
Plugin fixed https://github.com/albinotonnina/parcel-plugin-inlinesvg