Skip to content

webpack bundling broken in v1.1 #12721

Description

@submarines-and

Issue description

Recent changes break webpack bundles for pg.

Update in comment below: I think it is broken for all build types.

Expected Behavior

Changes made in this commit: (specifically the removed require statements) break webpack bundles https://github.com/typeorm/typeorm/pull/12647/changes

Previously, pg would be required by this file, but now that the import name is dynamic, the bundler does not know what to include so the pg package is missing in the compiled file, prompting error:

"Postgres package has not been found installed. Please run "npm install pg"."

Tried manually importing pg using import 'pg'; but to no avail.

Does these recent changes mean that webpack is no longer supported by typeorm?

Actual Behavior

Error on runtime

Postgres package has not been found installed. Please run "npm install pg".

Steps to reproduce

Install typeom + pg
Build using webpack, here is a sample config

module.exports = function (options) {
  const { plugins, ...config } = options;

  return {
    ...config,
    externals: [],
    plugins: [
      ...plugins,
      new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
    ],
  };
};

My Environment

Dependency Version
Operating System linux
Node.js version 22.22.3
Typescript version 6.0.3
TypeORM version 1.1.1

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • capacitor
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Activity

  1. submarines-and commented on Jul 20, 2026

    @submarines-and
    Author

    Actually, I think it may have broken for all build types. If I do a completely fresh project using:

    npx typeorm init --name MyProject --database postgres

    and then yarn &6 yarn start

    It breaks with the same error

    DriverPackageNotInstalledError: Postgres package has not been found installed. Please run "npm install pg".
    at PostgresDriver.loadDependencies (/Users/submarines/Downloads/MyProject/src/driver/postgres/PostgresDriver.ts:1719:19)
    at new PostgresDriver (/Users/submarines/Downloads/MyProject/src/driver/postgres/PostgresDriver.ts:370:14)
    at DriverFactory.create (/Users/submarines/Downloads/MyProject/src/driver/DriverFactory.ts:62:24)
    at new DataSource (/Users/submarines/Downloads/MyProject/src/data-source/DataSource.ts:142:43)
    at Object. (/Users/submarines/Downloads/MyProject/src/data-source.ts:5:30)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    at Module.m._compile (/Users/submarines/Downloads/MyProject/node_modules/ts-node/src/index.ts:1618:23)
    at node:internal/modules/cjs/loader:1913:10
    at Object.require.extensions. [as .ts] (/Users/submarines/Downloads/MyProject/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1505:32)

  2. changed the title [-]Webpack bundles (pg) broken in 1.1[/-] [+]Pg not found using v1.1[/+] on Jul 20, 2026
  3. added a commit that references this issue on Jul 22, 2026
    a411374
  4. changed the title [-]Pg not found using v1.1[/-] [+]webpack bundling broken in v1.1[/+] on Jul 22, 2026
  5. alumni commented on Jul 22, 2026

    @alumni
    Collaborator

    I was expecting that import 'pg' would work - I was forced to do something similar with webpack and pnpm even before this change.

    Do you happen to have some small repo with a reproduction example?

  6. OchirDarmaev commented on Jul 23, 2026

    @OchirDarmaev

    faced the same issue with esbuild
    error DriverPackageNotInstalledError2: Postgres package has not been found installed. Please run "npm install pg".

    Deps

    "typeorm": "^1.1.0",
    "pg": "^8.22.0",
    "esbuild": "^0.28.1",
    

    Solution: typeorm >=1.1 loads drivers via a dynamic require that esbuild cannot bundle — pass pg explicitly

    import pg from "pg";
    import { DataSource } from "typeorm";
    export const dataSource = new DataSource({
      type: "postgres",
      driver: pg,
  7. Mause commented on Oct 25, 2026

    @Mause

    I'm seeing the same issue with vite + react-router as well - #12729 fixes it for that combination too

  8. added 2 commits that reference this issue on Oct 25, 2026
    d72fb83
    013ad4d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions