Parcel: Parcel 2: Package Manager API

Created on 25 Oct 2019  ·  2Comments  ·  Source: parcel-bundler/parcel

❔ Question

Hello, as i'm using Parcel to make a testing tool, i was wondering if i could use the Package Manager that Parcel has, to install 'optional' dependencies on the fly when actually used.
Though i'm not sure how to use this package or if it's even possible to use it outside of Parcel ?

Could someone point me towards how to use it or tell me if it's not possible to do so.

Thanks :)

Waiting Question

All 2 comments

An example:

import {NodePackageManager} from '@parcel/package-manager';
import {NodeFS} from '@parcel/fs';

let packageManager = new NodePackageManager(new NodeFS());
let defaultConfig = await packageManager.require( // or .resolve
  '@parcel/config-default', // package specifier
  __filename // resolve from which file (not folder!)
);

Thanks, work like a charm 👍

Was this page helpful?
0 / 5 - 0 ratings