Remove dependency optionally at build time

I’m looking into removing a dependency at build time based on an environmental variable from process.env.

Looked at a few things:

  1. blacklist - doesn’t strip it from vendor.js
  2. Prod code only? - Remove a particular file/folder from the app tree depends upon the build environment

Is there a way to remove a dependency at build time in either ember-cli-build or does it have to be encapsulated in a separate addon?

I’ve done the inverse by only including a test file based on the environment:

// snippet from ember-cli-build
        const environment = EmberApp.env();
	const isTest = environment === 'test';
	if (isTest) {
		app.import('vendor/fixtures/my-test-file.csv', {type: 'test'});

This doesn’t answer your question directly but may help provide an opt-in scenario. Where is the dependency coming from too? The app, node_modules, or somewhere else?

This is wrong. blacklist does strip it from vendor.js.

This is another good thing to know! Thank you!

1 Like