question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

make global packages be accessible to the optimized bundle

See original GitHub issue

Hi,

I am using sequelize and it is required that I do npm install mysql2 --save before the code works.

i tried this config

custom:
  optimize:
    debug: true
    minify: true
    plugins: ['transform-object-rest-spread']
    includePaths: ['.env.example']
    external: ['mysql2']

but i still get this error You need to install mysql2 package manually i can see the node_modules folder on the zip file but i suspect it’s placed on the wrong folder?

i also tried

require('mysql2');

on my handler but it failed, i think it wasn’t able to get the dependencies of mysql2

What could I possibly do to overcome this issue using this plugin? Will appreciate any help. Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
selected-pixel-jamesoncommented, Nov 15, 2018

Thank you. I’ll check that out.

0reactions
uehondorcommented, May 31, 2022

@selected-pixel-jameson @shierro I had the same issue as you both and solved it by doing the following:

  • Manually install mysql2, so npm install --save mysql2
  • Initiliase the sequelize object with mysql2 module. See require(‘mysql2’) below:
const sequelize = new Sequelize(
    process.env.DB_NAME,
    process.env.DB_USER,
    process.env.DB_PASSWORD,
    {
        dialect: 'mysql',
        // this ensures sequelize uses the mysql2 module you supply
        // and ensures it's included in the optimized bundle because the require is explicit
        dialectModule: require('mysql2'),
        host: process.env.DB_HOST,
        port: process.env.DB_PORT
  }
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Slimming down your bundle size - LogRocket Blog
This strategy for bundle optimization and slimming down total bundle size is easy and straightforward. Webpack has a production flag ( -p )...
Read more >
GitHub - AnomalyInnovations/serverless-bundle
Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration. - GitHub - AnomalyInnovations/serverless-bundle: Optimized ...
Read more >
Bundling and Minification | Microsoft Learn
Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle multiple files into a single file. You...
Read more >
How to add reference to System.Web.Optimization for MVC-3 ...
I'm trying to use the new bundling feature in a project I recently converted from MVC 3 to MVC 4 beta. It requires...
Read more >
bundle install - Bundler
Makes a bundle that can work without depending on Rubygems or Bundler at runtime. A space separated list of groups to install has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found