Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave specific require() as-is? #4547

Closed
thesoftwarephilosopher opened this issue Apr 29, 2020 · 2 comments
Closed

Leave specific require() as-is? #4547

thesoftwarephilosopher opened this issue Apr 29, 2020 · 2 comments

Comments

@thesoftwarephilosopher
Copy link

🙋 feature request

An option/flag to tell Parcel to ignore a specific require and leave it as-is instead of bundling it.

🤔 Expected Behavior

const options = {
   // ...
  ignoreModules: ['aws-sdk'],
};

Output file:

const AWS = require('aws-sdk'); // provided from deployment environment
// use AWS

😯 Current Behavior

No such option exists. All packages are bundled up. Output file:

const AWS = /* embedded AWS SDK source code */;
// use AWS

💁 Possible Solution

Add the option, so that the given packages are not bundled up.

🔦 Context

Parcel is used by AWS CDK to bundle up NodeJS modules for deployment to AWS Lambda.

However, AWS Lambda has a size limit on the uploaded bundle.

But AWS Lambda also provides the require function at runtime, as well as the aws-sdk.

So if Parcel had an option to leave require('aws-sdk') as-is, then I could upload my code to AWS Lambda.

💻 Examples

See above.

@mischnic
Copy link
Member

mischnic commented Apr 29, 2020

As a workaround you try to "outsmart" Parcel with: 😬

let foo = "aws-sdk";
const AWS = require(foo);

Does this work for you?

ignoreModules: ['aws-sdk']

Parcel 2 has something like that already implemented:

{
	"app": "dist/index.js",
	"targets": {
		"default": {
			"includeNodeModules": { "aws-sdk": false }
		}
	},
	"engines": {
		"node": ">=10"
	}
}

@thesoftwarephilosopher
Copy link
Author

The workaround works well enough for now, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants