You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version 0.2.0 added support for migrations! In that update, a new index-imported top-level file, src/fs-migration-source.ts, was added, which imports the following from knex:
Unfortunately the knex package does not declare itself as "sideEffects": false the way kysely-knex does. As such, this import is not treeshaken away when not needed - even when KyselyFsMigrationSource is treeshaken away.
This issue manifests itself further downstream: Packages that import kysely-knex will end up bundling that particular knex file, which itself includes various imports from path, os etc. (potentially problematic in certain runtimes) and further bloats bundle outputs.
Repro
I can spin up a proper repro if requested, but basic, minimal example looks like this:
Worst case this file, when bundled, will already include the entire fs-migrations.js file knex.
Best case, when declaring knex as external dependency, the dist output may look something like this (exact output depends on the bundler, target, etc.):
However, the next package that utilizes this, without declaring knex (or specifically knex/lib/migrations/migrate/sources/fs-migrations.js) as external, will in turn bundle said knex file into its dist output.
The text was updated successfully, but these errors were encountered:
There may be better ways to handle this, but two potential solutions off the top of my head:
A: somehow mark knex/lib/migrations/migrate/sources/fs-migrations.js as tree-shakable? Unsure if this can be done in this package without requiring upstream changes to the knex package.
B: perhaps move the migrations feature out of the top-level index exports and into a separate subpath export? This would bypass the issue, but also represent a breaking change: Migration features would then need to be imported e.g. via import {KyselyFsMigrationSource} from 'kysely-knex/migrate'.
Issue
Version
0.2.0
added support for migrations! In that update, a new index-imported top-level file,src/fs-migration-source.ts
, was added, which imports the following fromknex
:Unfortunately the
knex
package does not declare itself as"sideEffects": false
the waykysely-knex
does. As such, this import is not treeshaken away when not needed - even whenKyselyFsMigrationSource
is treeshaken away.This issue manifests itself further downstream: Packages that import
kysely-knex
will end up bundling that particular knex file, which itself includes various imports frompath
,os
etc. (potentially problematic in certain runtimes) and further bloats bundle outputs.Repro
I can spin up a proper repro if requested, but basic, minimal example looks like this:
Worst case this file, when bundled, will already include the entire
fs-migrations.js
file knex.Best case, when declaring knex as external dependency, the dist output may look something like this (exact output depends on the bundler, target, etc.):
However, the next package that utilizes this, without declaring
knex
(or specificallyknex/lib/migrations/migrate/sources/fs-migrations.js
) as external, will in turn bundle said knex file into its dist output.The text was updated successfully, but these errors were encountered: