Skip to content

Feature: Packaging updates #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 26, 2025
Merged

Feature: Packaging updates #39

merged 13 commits into from
Apr 26, 2025

Conversation

seangwright
Copy link
Owner

@seangwright seangwright commented Apr 8, 2025

This PR removes the old commonjs bundling added for #3 since NestJs no longer requires commonjs packages.
It also updates npm deps and the GitHub actions used to build and deploy this library.

This is a major breaking change so we'll release a new v3.0.0 once this branch is merged in.

We'll want to test a pre-release package of this new bundling before full release.

  • Unpkg
  • https://bolt.new/
  • Traditional local npm + TS project
  • Minimal framework (ex: Next/Nuxt/SvelteKit)

@seangwright
Copy link
Owner Author

@GregOnNet want to test things out with me?

There's a pre-release v3.0.0 being built from this branch
https://www.npmjs.com/package/typescript-functional-extensions?activeTab=versions

We can use it in all the environments mentioned above.

@GregOnNet
Copy link
Contributor

Sure thing.
I have a small Open Source NestJS application, where I can install and test the pre-Release

@GregOnNet
Copy link
Contributor

GregOnNet commented Apr 9, 2025

Hey @seangwright ,

I cannot use version 3, yet (see image below).
Maybe it is, because I have NestJS setup with CommonJS.
Currently, I was not able to migrate to ESM.
I did not find a guide for this, either, but this issue nestjs/nest#13319.

It seems the NestJS had no plans to go for ESM... at least last year

CleanShot 2025-04-09 at 20 16 19@2x

Environment

  • Nest 10
  • Nx 20.7

Steps to reproduce

If you like... I pushed a branch of my app with the erroring setup: https://github.com/entwicklungszeit/papierkram-devkit/pull/3/files#diff-b1c724f5160fdda14108ce318e3db1ee732602cf66e15917e84df8f14e90d9c6R9

@seangwright
Copy link
Owner Author

seangwright commented Apr 9, 2025

Huh. I thought I saw esm was finally usable in a recent Nestjs release, but maybe I imagined it!

I'll revert the switch to esm-only but keep some of the other build improvements and create a new pre-release package.

--- edit

It appears an experimental feature in node v22.4.0 supports esm via cjs but that seems like a lot of ask from nestjs users.

@seangwright
Copy link
Owner Author

@GregOnNet
Copy link
Contributor

Thanks,

combine aka combineAsync is missing.
combineInOrder is available.

Seems combine has been removed by accident.

@GregOnNet
Copy link
Contributor

Installed version: "typescript-functional-extensions": "3.0.0-prerelease.25-1"

After starting NestJS, I receive a runtime-error:

ReferenceError: exports is not defined in ES module scope
    at file:///.../papierkram-devkit/node_modules/.pnpm/[email protected]/node_modules/typescript-functional-extensions/dist/cjs/index.js:16:23
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:395:35)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:329:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1414:24)
    at Module._compile (node:internal/modules/cjs/loader:1547:5)
    at Object..js (node:internal/modules/cjs/loader:1677:16)
    at Module.load (node:internal/modules/cjs/loader:1318:32)
    at Function.<anonymous> (node:internal/modules/cjs/loader:1128:12)
    at Function.Module._load (/.../papierkram-devkit/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@swc+hel_e52e0475112c02866965c91ec03de25f/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:18:31)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)

Installed cjs/index.js

I am not familiar with module compatibilities.
It seems like the CJS defines __esModule

CleanShot 2025-04-12 at 20 57 44@2x

@GregOnNet
Copy link
Contributor

GregOnNet commented Apr 12, 2025

I pushed the current version containing the error to entwicklungszeit/papierkram-devkit#3

Steps to reproduce

  • git clone https://github.com/entwicklungszeit/papierkram-devkit.git
  • git checkout ref/railway
  • pnpm install
  • pnpm nx run papierkram-devkit-api:serve

@seangwright
Copy link
Owner Author

seangwright commented Apr 26, 2025

Thanks,

combine aka combineAsync is missing. combineInOrder is available.

Seems combine has been removed by accident.

@GregOnNet something happened with your remote branches that were merged in with both of these PRs

They include most of the same commits, but #35 includes 1 additional commit - f7f9e12.

That additional commit overwrote the changes you made to add combine with the new combineInOrder
f7f9e12

This is why it's missing from the library now.

@seangwright
Copy link
Owner Author

@GregOnNet I re-added the combine methods and tests and updated the build process which should hopefully fix the cjs package.

Also, I tested the latest version of the package using a vanilla NextJs app using this method https://docs.nestjs.com/#alternatives and it worked correctly.

I'm ready to merge this in if everything looks good to you.

@GregOnNet
Copy link
Contributor

GregOnNet commented Apr 26, 2025

Hey @seangwright,

everything works in my example project.
Tested combine as well.

LGTM

@seangwright seangwright merged commit 6f304dc into main Apr 26, 2025
3 of 4 checks passed
@seangwright seangwright deleted the feat/packaging-updates branch May 1, 2025 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants