parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.52k stars 2.27k forks source link

Provide a way to configure targets outside package.json #5023

Open jogold opened 4 years ago

jogold commented 4 years ago

🙋 feature request

Parcel should provide a way to configure targets outside the package.json, either via the CLI (with v1 it was possible to pass all the configuration) or in another file.

🤔 Expected Behavior

Be able to fully configure a build without "touching" the package.json

😯 Current Behavior

Currently not possible

🔦 Context

Parcel is currently being used in the AWS CDK (AWS Cloud Development Kit) library to bundle Lambda functions written in JavaScript or Typesript.

The module @aws-cdk/aws-lambda-nodejs offers this feature.

It works by extracting/finding entries of Lambda functions defined in a stack and then automatically bundles them for the user when the AWS CDK app gets synthesized. Unfortunately, in order to offer this "it just works" experience we have to temporarily update the user's package.json with some Parcel configuration, run a Parcel build and then revert the file to its original content. This is not clean.

💻 Examples

$ parcel build /my/entry/file.ts --target-config target.json

OR (bring back CLI parameters when the entry file is specified)

$ parcel build /my/entry/file.ts --context node ...
mischnic commented 4 years ago

targets outside the package.json,

This is possible from the API: https://github.com/parcel-bundler/parcel/blob/803ec9700bdd384b5b8bfedd41f2398494094776/packages/core/types/index.js#L255

CLI parameters when the entry file is specified

You can specify entries on the CLI, you mean --context?

jogold commented 4 years ago

Ideally I would like to fully configure a target from the CLI (context, includeNodeModules, engines).

Also when developing with the API in TypeScript where can I find the definition files (.d.ts) for @parcel/core?

mischnic commented 4 years ago

We use Flow for Parcel itself, so there are no TS definitons yet.

The plan is to create proper Flow libdefs and then convert them to TS at some point (https://github.com/parcel-bundler/parcel/issues/3912,https://github.com/parcel-bundler/parcel/issues/3720, https://github.com/parcel-bundler/parcel/issues/3720)