#✅ extension packaging for external imports

25 messages · Page 1 of 1 (latest)

hardy coral
#

Hi Greetings,

I have below imports in my extension:

import { defineEndpoint } from '@directus/extensions-sdk';
import { Request, Response } from 'express';
import axios from 'axios';
import { knex as knexfunc, Knex } from 'knex';

Just wondering if express/axios/knex will also be packed into the generated index.js (or api.js for bundle) file?
I believe they are already inside somewhere under node_modules, shall I do some configuration to reduce the generated file size?

BR,Austin

trail treeBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please make sure your question includes the following:

  • An explanation of exactly what you're trying to achieve.
  • Any and all related code or previous attempts.
  • The exact issue or error you are facing.
  • Any screenshots if applicable.

When you're done with this thread, please close it.

(If you have a support agreement and need help, please contact the core team via email.)

river pasture
hardy coral
#

thanks @trail tree I installed them already in node_modules, how to tell the package no need to put them into the generated index.js file?

#

Thanks goes to @river pasture and directuslight

river pasture
hardy coral
#

One step to close...I installed them already in node_modules, how to tell the package no need to put them into the generated index.js file?

#

@trail tree

#

@river pasture

river pasture
hardy coral
# river pasture npm r module_name

I believe this is to remove module_name from node_modules directory... I want to keep them, and ask "directus-extension build" to use them instead of putting all the modules into the generated index.js. @river pasture

river pasture
#

It doesnt work that way

#

The buildcommand will make an independend file that contains everything to run your extension

#

You can allow it to use external modules by not having them available in your node modules

#

Because directus has them build in, this will work just fine

hardy coral
#

ah... I see. So I remove them from the npm_modules under extension project folder, but keep them inside the npm_modules under the directus project folder.

river pasture
#

No need to install them at all

#

Directus does that automatically for you

hardy coral
#

ok. how can I make sure if a module is included by directus or not?

river pasture
#

if its included there, you should be fine

trail treeBOT
#

✅ extension packaging for external imports

trail treeBOT
narrow hawk
#

@minor jay is this, what you're looking for?