Skip to content

Commit 5c77946

Browse files
committed
feat: upgrade all packages to publish in ESM format as well as CommonJS
1 parent a84e2f2 commit 5c77946

33 files changed

+3332
-2676
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ retire-cache
88
testReports
99
tslint-report.json
1010
packages/*/lib
11+
packages/*/dist
12+
packages/*/out
1113
/coverage
1214
/packages/cli/dist
1315
*.tgz

.npmrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
hoist=true
2-
node-linker=isolated
3-
public-hoist-pattern[]['*eslint*', '*prettier*', '@oclif/command']
4-
package-import-method=clone-or-copy
51
strict-peer-dependencies=false
62
prefer-workspace-packages=true
73
shell-emulator=true

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
}
7676
}
7777
],
78-
"dependsOn": ["watch-vlocity-deploy"]
78+
//"dependsOn": ["watch-vlocity-deploy"]
7979
},
8080
{
8181
"label": "watch-cli",

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@types/node": "~20.17",
3333
"@typescript-eslint/eslint-plugin": "^8.1.0",
3434
"@typescript-eslint/parser": "^8.1.0",
35-
"chalk": "^4.1.2",
35+
"esbuild": "^0.25.4",
3636
"eslint": "^8.57.0",
3737
"eslint-config-prettier": "^8.10.0",
3838
"eslint-plugin-import": "^2.29.1",
@@ -45,7 +45,7 @@
4545
"jest-junit": "^16.0.0",
4646
"jest-sonar": "^0.2.16",
4747
"js-yaml": "^4.1.0",
48-
"lint-staged": "^13.1.0",
48+
"lint-staged": "^16.0.0",
4949
"log-symbols": "^4.1.0",
5050
"prettier": "^3.3.3",
5151
"ts-jest": "^29.3.4",
@@ -138,11 +138,9 @@
138138
"@salesforce/core@^3": "3.31.18",
139139
"@salesforce/core@^2": "2.37.1",
140140
"@types/jsforce": "1.9.42",
141-
"chalk": "^4.1.2",
142141
"js-yaml": "^4.1.0",
143142
"typescript": "5.1.6",
144143
"xml2js": "^0.5.0",
145-
"esbuild": "^0.20.1",
146144
"jsonwebtoken": "^9.0.0",
147145
"braces": "^3.0.3",
148146
"punycode": "^2.3.1"

packages/apex/package.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
"Parser",
1010
"Grammar"
1111
],
12-
"main": "lib/index.js",
12+
"main": "src/index.ts",
1313
"publishConfig": {
14-
"main": "lib/index.js",
15-
"typings": "lib/index.d.ts"
14+
"main": "dist/index.cjs",
15+
"module": "dist/index.mjs",
16+
"typings": "dist/index.d.ts"
1617
},
1718
"readme": "../SITE.md",
1819
"directories": {
@@ -22,11 +23,13 @@
2223
"node": ">=20.0.0"
2324
},
2425
"scripts": {
25-
"build": "tsc",
26-
"clean": "shx rm -rf ./lib ./coverage ./tsconfig.tsbuildinfo './*.tgz' './src/**/*.{d.ts,ts.map,js.map,js}'",
27-
"watch": "tsc -w",
28-
"pack": "pnpm run build && pnpm pack",
29-
"prepublish": "pnpm run build",
26+
"clean": "shx rm -rf ./lib ./dist ./coverage ./tsconfig.tsbuildinfo './*.tgz' './src/**/*.{d.ts,ts.map,js.map,js}'",
27+
"build": "tsc --emitDeclarationOnly && pnpm bundle",
28+
"bundle": "node ../../scripts/esbuild.mjs --entrypoint ./src/index.ts",
29+
"watch": "pnpm bundle --watch",
30+
"pack": "pnpm build && pnpm pack",
31+
"prepublish": "pnpm build",
32+
"test": "jest",
3033
"build-grammar": "antlr4ng -Dlanguage=TypeScript -o ./src/grammar -visitor -listener ./grammar/ApexLexer.g4 ./grammar/ApexParser.g4"
3134
},
3235
"repository": {
@@ -38,8 +41,9 @@
3841
"email": "[email protected]"
3942
},
4043
"files": [
41-
"lib/**/*.d.ts",
42-
"lib/**/*.js",
44+
"dist/**/*.d.ts",
45+
"dist/index.cjs",
46+
"dist/index.mjs",
4347
"lib/**/*.json",
4448
"patches/*.patch",
4549
"../SITE.md"
@@ -58,6 +62,7 @@
5862
"@types/node": "~20.17",
5963
"@types/tough-cookie": "^4.0.2",
6064
"antlr4ng-cli": "^2.0.0",
65+
"esbuild": "^0.25.4",
6166
"jest": "^29.7.0",
6267
"nugget": "^2.2.0",
6368
"shx": "^0.3.4",

packages/apex/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "../../tsconfig",
33
"compilerOptions": {
44
"composite": true,
5-
"outDir": "lib",
5+
"module": "esnext",
6+
"outDir": "dist",
67
"rootDir": "src",
78
"declaration": true,
89
"declarationMap": true,

packages/cli/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
"Datapacks",
99
"Deployment"
1010
],
11-
"main": "lib/index.js",
1211
"bin": {
1312
"vlocode": "bin/run"
1413
},
14+
"main": "src/index.ts",
1515
"publishConfig": {
16-
"main": "lib/index.js",
17-
"typings": "lib/index.d.ts"
16+
"main": "dist/cli.js"
1817
},
1918
"readme": "./README.md",
2019
"directories": {
@@ -62,15 +61,15 @@
6261
"@vlocode/util": "workspace:*",
6362
"@vlocode/vlocity": "workspace:*",
6463
"@vlocode/vlocity-deploy": "workspace:*",
65-
"chalk": "^4.1.1",
64+
"chalk": "^5.4.1",
6665
"commander": "^11.1.0",
66+
"esbuild": "^0.25.4",
6767
"esbuild-loader": "^4.3.0",
6868
"glob": "^11.0.2",
6969
"jest": "^29.7.0",
7070
"js-yaml": "^4.1.0",
7171
"log-symbols": "^4.0.0",
7272
"shx": "^0.3.4",
73-
"source-map-support": "^0.5.21",
7473
"ts-jest": "^29.3.4",
7574
"ts-loader": "^9.5.2",
7675
"ts-node": "^10.9.2",

packages/cli/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as path from 'path';
44
import { Command, Option } from 'commander';
55
import { FancyConsoleWriter, container, Logger, LogLevel, LogManager, ConsoleWriter } from '@vlocode/core';
66
import { getErrorMessage } from '@vlocode/util';
7-
import { Command as CliCommand } from './command';
87

98
// @ts-ignore
109
const nodeRequire = typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : require;
@@ -38,7 +37,6 @@ class CLI {
3837
if (CLI.isVerbose || CLI.isDebug) {
3938
LogManager.registerWriter(new FancyConsoleWriter());
4039
if (CLI.isDebug) {
41-
import('source-map-support/register');
4240
LogManager.setGlobalLogLevel(LogLevel.debug);
4341
} else {
4442
LogManager.setGlobalLogLevel(LogLevel.verbose);
@@ -62,6 +60,7 @@ class CLI {
6260

6361
constructor(private commandsFolder: string) {
6462
this.logger.verbose(this.versionString);
63+
debugger; // eslint-disable-line no-debugger
6564
this.program = new Command()
6665
.name(CLI.programName)
6766
.description(CLI.description)

packages/cli/tsconfig.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
{
22
"extends": "../../tsconfig",
33
"compilerOptions": {
4-
"outDir": "lib",
4+
"outDir": "dist",
55
"rootDir": "src",
66
"baseUrl": "src",
77
"declaration": true,
88
"declarationMap": true
99
},
10-
"include": ["src/**/*"],
11-
"references": [
12-
{ "path": "../util" },
13-
{ "path": "../apex" },
14-
{ "path": "../core" },
15-
{ "path": "../salesforce" },
16-
{ "path": "../vlocity" },
17-
{ "path": "../omniscript" },
18-
{ "path": "../vlocity-deploy" }
19-
]
10+
"include": ["src/**/*"]
2011
}

packages/cli/webpack/webpack.mjs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { glob } from 'glob';
33
import webpack from 'webpack';
44
import { existsSync, readFileSync, readdirSync } from 'fs';
55
import { EsbuildPlugin } from 'esbuild-loader';
6+
import { sourceMapsEnabled } from 'process';
67

78
const packageExternals = [
89
'vscode',
@@ -28,6 +29,7 @@ const common = {
2829
name: 'vlocode-cli',
2930
mode: 'production',
3031
context: contextFolder,
32+
devtool: 'source-map',
3133
target: 'node',
3234
entry:
3335
glob.sync(
@@ -85,7 +87,6 @@ const common = {
8587
__filename: false
8688
},
8789
optimization: {
88-
runtimeChunk: false,
8990
concatenateModules: true,
9091
mergeDuplicateChunks: true,
9192
mangleExports: false,
@@ -94,16 +95,11 @@ const common = {
9495
providedExports: false,
9596
usedExports: false,
9697
portableRecords: true,
97-
splitChunks: false,
98-
minimize: true,
99-
minimizer: [
100-
new EsbuildPlugin({
101-
target: 'es2020',
102-
keepNames: true,
103-
minify: true,
104-
legalComments: 'external'
105-
})
106-
]
98+
minimize: false,
99+
splitChunks: {
100+
minSize: 20000,
101+
chunks: 'all'
102+
},
107103
},
108104
externals: function({ request }, callback) {
109105
const isExternal = packageExternals.some(

packages/core/package.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "@vlocode/core",
33
"version": "1.28.2",
44
"description": "Vlocode core IoC container framework library",
5-
"main": "lib/index.js",
5+
"main": "src/index.ts",
66
"publishConfig": {
7-
"main": "lib/index.js",
8-
"typings": "lib/index.d.ts"
7+
"main": "dist/index.cjs",
8+
"module": "dist/index.mjs",
9+
"typings": "dist/index.d.ts"
910
},
1011
"readme": "../SITE.md",
1112
"directories": {
@@ -15,11 +16,12 @@
1516
"node": ">=20.0.0"
1617
},
1718
"scripts": {
18-
"build": "tsc",
19-
"clean": "shx rm -rf ./lib ./coverage ./tsconfig.tsbuildinfo './src/**/*.{d.ts,ts.map,js.map,js}'",
20-
"watch": "tsc -w",
19+
"clean": "shx rm -rf ./lib ./dist ./coverage ./tsconfig.tsbuildinfo './*.tgz' './src/**/*.{d.ts,ts.map,js.map,js}'",
20+
"build": "tsc --emitDeclarationOnly && pnpm bundle",
21+
"bundle": "node ../../scripts/esbuild.mjs --entrypoint ./src/index.ts",
22+
"watch": "pnpm bundle --watch",
2123
"pack": "pnpm pack",
22-
"prepublish": "pnpm run build"
24+
"prepublish": "pnpm build"
2325
},
2426
"repository": {
2527
"type": "git",
@@ -30,8 +32,9 @@
3032
"email": "[email protected]"
3133
},
3234
"files": [
33-
"lib/**/*.d.ts",
34-
"lib/**/*.js",
35+
"dist/**/*.d.ts",
36+
"dist/index.cjs",
37+
"dist/index.mjs",
3538
"patches/*.patch",
3639
"../SITE.md"
3740
],
@@ -44,14 +47,15 @@
4447
"@types/jest": "^29.5.11",
4548
"@types/luxon": "^3.3.0",
4649
"@types/node": "~20.17",
50+
"esbuild": "^0.25.4",
4751
"jest": "^29.7.0",
4852
"shx": "^0.3.4",
4953
"ts-jest": "^29.3.4",
5054
"typescript": "5.1.6"
5155
},
5256
"dependencies": {
5357
"@vlocode/util": "workspace:*",
54-
"chalk": "^4.1.1",
58+
"chalk": "^5.4.1",
5559
"fast-glob": "^3.3.3",
5660
"luxon": "^3.4.4",
5761
"memfs": "^4.17.0",

packages/core/src/logging/writers/fancyConsoleWriter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LogWriter, LogEntry, LogLevel } from '..';
2-
import chalk from 'chalk';
2+
import { Chalk } from 'chalk';
33
import { DateTime } from 'luxon';
44

55
export class FancyConsoleWriterOptions {
@@ -12,7 +12,7 @@ export class FancyConsoleWriterOptions {
1212
export class FancyConsoleWriter implements LogWriter {
1313

1414
private readonly options: FancyConsoleWriterOptions;
15-
private readonly chalk = new chalk.Instance({ level: 2 });
15+
private readonly chalk = new Chalk({ level: 2 });
1616
private readonly colors = {
1717
[LogLevel.debug]: this.chalk.magenta,
1818
[LogLevel.verbose]: this.chalk.dim,

packages/core/src/logging/writers/terminalWriter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as vscode from 'vscode';
2-
import chalk from 'chalk';
2+
import { Chalk } from 'chalk';
33
import { DateTime } from 'luxon';
44
import { LogLevel, LogWriter, LogEntry } from '../../logging';
55

@@ -18,7 +18,8 @@ export class TerminalWriter implements LogWriter {
1818
private terminalWatchdog? : any;
1919
private isOpened = false;
2020
private readonly queuedMessages : LogEntry[] = [];
21-
private readonly chalk = new chalk.Instance({ level: 2 });
21+
private readonly chalk = new Chalk({ level: 2 });
22+
// eslint-disable-next-line @typescript-eslint/no-require-imports
2223
private readonly vscode: typeof vscode = require('vscode');
2324
private readonly colors = {
2425
[LogLevel.debug]: this.chalk.magenta,

packages/core/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../../tsconfig",
33
"compilerOptions": {
44
"composite": true,
5-
"outDir": "lib",
5+
"outDir": "dist",
66
"rootDir": "src",
77
"declaration": true,
88
"declarationMap": true

0 commit comments

Comments
 (0)