Skip to content

Commit

Permalink
MINMAL WIP FUBAR FIX: get Nx lib and Node app working with ESM and "t…
Browse files Browse the repository at this point in the history
…ype": "module" (albeit with many caveats)

1. You have to physically remove every last vestige of Jest anything (even it just being there in the dir breaks shit)

2. You have to set bundle: true for the app although I guess maybe that is oK

3. You have to enable "allowImportingTsExtensions" which is awesome but will break other shit
  • Loading branch information
protiev committed Jun 9, 2024
1 parent 211d073 commit cf0795b
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/axhxrx-nx-esm-fuckery/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"platform": "node",
"outputPath": "dist/apps/axhxrx-nx-esm-fuckery",
"format": ["esm"],
"bundle": false,
"bundle": true,
"main": "apps/axhxrx-nx-esm-fuckery/src/main.ts",
"tsConfig": "apps/axhxrx-nx-esm-fuckery/tsconfig.app.json",
"assets": ["apps/axhxrx-nx-esm-fuckery/src/assets"],
Expand Down
1 change: 0 additions & 1 deletion apps/axhxrx-nx-esm-fuckery/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
Expand Down
2 changes: 1 addition & 1 deletion libs/nx-buildable-esbuild-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@local/nx-buildable-esbuild-lib",
"version": "0.0.1",
"dependencies": {},
"type": "commonjs",
"type": "module",
"main": "./index.cjs",
"private": true
}
5 changes: 3 additions & 2 deletions libs/nx-buildable-esbuild-lib/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"main": "libs/nx-buildable-esbuild-lib/src/index.ts",
"tsConfig": "libs/nx-buildable-esbuild-lib/tsconfig.lib.json",
"assets": ["libs/nx-buildable-esbuild-lib/*.md"],
"generatePackageJson": true,
"format": ["cjs"]
"format": [
"esm"
]
}
},
"test": {
Expand Down
6 changes: 3 additions & 3 deletions libs/nx-buildable-esbuild-lib/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './lib/nx-buildable-esbuild-lib';
export * from './lib/Animal';
export * from './lib/Tarantula';
export * from './lib/nx-buildable-esbuild-lib.ts';
export * from './lib/Animal.ts';
export * from './lib/Tarantula.ts';
2 changes: 1 addition & 1 deletion libs/nx-buildable-esbuild-lib/src/lib/Tarantula.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Animal } from './Animal';
import { Animal } from './Animal.ts';

export class Tarantula extends Animal
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { nxBuildableEsbuildLib } from './nx-buildable-esbuild-lib';
import { Animal } from './Animal';
import { nxBuildableEsbuildLib } from './nx-buildable-esbuild-lib.ts';
import { Animal } from './Animal.ts';

describe('nxBuildableEsbuildLib', () => {
it('should work', () => {
Expand Down
1 change: 0 additions & 1 deletion libs/nx-buildable-esbuild-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"moduleResolution": "Bundler",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"allowImportingTsExtensions": true,
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
Expand Down

0 comments on commit cf0795b

Please sign in to comment.