-
-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert messages into a hybrid cjs/esm package (#1756)
* Convert cucumber-expressions into a module * Use a root-level tsconfig.esm.json file That way we will avoid duplication of ts-node section in packages tsconfig.json. Once all module have been converted, we will be able to move the ts-node configuration into the root level tsconfig.json. * Update TypeScript builds to consider legacy and new esm-compatible ones * Add a dedicated template for javascript esm-compatible packages * Add the specific cjs package.json to javascript-esm template * Fix 'npm run clean' scripts to avoid deleting the 'javascript/dist/cjs/package.json' files * Add an entry in the CHANGELOG after merge of main * Update javascript-esm/default.mk with the last version of javascript/default.mk * Add tests to make sure the CJS build works well * Fix make clean targets for hybrid esm/cjs packages * Convert messages into a hybrid cjs/esm package * Fix tsconfig build files * Fix make clean for messages javascript * Fix Makefile clean target * Convert message-streams to hybrid cjs/esm: rsync * Convert message-streams to hybrid cjs/esm: convert the package * Use lib: es2019 in tsconfig * [skip ci]Update changelogs * Fix json-formatter package.json * Manage dist/cjs/package.json another way * Fix templates for esm package * Remove jsnext:main from package.json Co-authored-by: Aslak Hellesøy <[email protected]>
- Loading branch information
1 parent
23404c7
commit f1570e2
Showing
37 changed files
with
2,212 additions
and
3,018 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
dist/* | ||
!dist/cjs | ||
dist/cjs/* | ||
!dist/cjs/package.json | ||
dist/ | ||
.idea/ | ||
.nyc_output/ | ||
coverage/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../../.templates/javascript/ . | ||
../../.templates/javascript-esm/ . |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,34 @@ | |
"name": "@cucumber/message-streams", | ||
"version": "3.0.0", | ||
"description": "Streams for reading/writing messages", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"type": "module", | ||
"main": "dist/cjs/src/index.js", | ||
"types": "dist/cjs/src/index.d.ts", | ||
"files": [ | ||
"dist/cjs", | ||
"dist/esm" | ||
], | ||
"module": "dist/esm/src/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/src/index.js", | ||
"require": "./dist/cjs/src/index.js" | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/cucumber/cucumber.git" | ||
}, | ||
"author": "Cucumber Limited <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "mocha", | ||
"prepublishOnly": "tsc --build tsconfig.build.json" | ||
"build:cjs": "tsc --build tsconfig.build-cjs.json", | ||
"build:esm": "tsc --build tsconfig.build-esm.json", | ||
"build": "npm run build:cjs && npm run build:esm", | ||
"postbuild:cjs": "cp package.cjs.json dist/cjs/package.json", | ||
"test": "mocha && npm run test:cjs", | ||
"test:cjs": "npm run build:cjs && mocha --no-config dist/cjs/test", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"dependencies": { | ||
"@cucumber/messages": "^17.1.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import MessageToNdjsonStream from './MessageToNdjsonStream' | ||
import NdjsonToMessageStream from './NdjsonToMessageStream' | ||
import MessageToNdjsonStream from './MessageToNdjsonStream.js' | ||
import NdjsonToMessageStream from './NdjsonToMessageStream.js' | ||
|
||
export { MessageToNdjsonStream, NdjsonToMessageStream } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ge-streams/javascript/tsconfig.build.json → ...treams/javascript/tsconfig.build-cjs.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"extends": "../../tsconfig.build-cjs.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "dist" | ||
"outDir": "dist/cjs" | ||
}, | ||
"include": [ | ||
"src", | ||
"test" | ||
] | ||
], | ||
} |
7 changes: 3 additions & 4 deletions
7
messages/javascript/tsconfig.build.json → ...treams/javascript/tsconfig.build-esm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"extends": "../../tsconfig.build-esm.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "dist" | ||
"outDir": "dist/esm" | ||
}, | ||
"include": [ | ||
"package.json", | ||
"src", | ||
"test" | ||
] | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json" | ||
"extends": "../../tsconfig.esm.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
../../LICENSE LICENSE | ||
../../.templates/github/ .github/ | ||
../../.templates/javascript/ . | ||
../../.templates/javascript-esm/ . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,24 +2,41 @@ | |
"name": "@cucumber/messages", | ||
"version": "17.1.1", | ||
"description": "JSON schema-based messages for Cucumber's inter-process communication", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"type": "module", | ||
"main": "dist/cjs/src/index.js", | ||
"types": "dist/cjs/src/index.d.ts", | ||
"files": [ | ||
"dist/cjs", | ||
"dist/esm" | ||
], | ||
"module": "dist/esm/src/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/src/index.js", | ||
"require": "./dist/cjs/src/index.js" | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/cucumber/messages-javascript.git" | ||
}, | ||
"author": "Cucumber Limited <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"build:cjs": "tsc --build tsconfig.build-cjs.json", | ||
"build:esm": "tsc --build tsconfig.build-esm.json", | ||
"build": "npm run build:cjs && npm run build:esm", | ||
"postbuild:cjs": "cp package.cjs.json dist/cjs/package.json", | ||
"prepare": "make src/messages.ts", | ||
"test": "mocha", | ||
"prepublishOnly": "tsc --build tsconfig.build.json" | ||
"test": "mocha && npm run test:cjs", | ||
"test:cjs": "npm run build:cjs && mocha --no-config dist/cjs/test", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"dependencies": { | ||
"@types/uuid": "8.3.1", | ||
"uuid": "8.3.2", | ||
"class-transformer": "0.4.0", | ||
"reflect-metadata": "0.1.13" | ||
"reflect-metadata": "0.1.13", | ||
"uuid": "8.3.2" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "9.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import * as TimeConversion from './TimeConversion' | ||
import * as IdGenerator from './IdGenerator' | ||
import { version } from '../package.json' | ||
import { parseEnvelope } from './parseEnvelope' | ||
import { getWorstTestStepResult } from './getWorstTestStepResult' | ||
import * as TimeConversion from './TimeConversion.js' | ||
import * as IdGenerator from './IdGenerator.js' | ||
import { parseEnvelope } from './parseEnvelope.js' | ||
import { getWorstTestStepResult } from './getWorstTestStepResult.js' | ||
import { version } from './version.js' | ||
|
||
export * from './messages' | ||
export * from './messages.js' | ||
|
||
export { TimeConversion, IdGenerator, version, parseEnvelope, getWorstTestStepResult } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file is generated using `make src/version.ts` or `make .codegen` | ||
export const version = '17.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build-cjs.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "dist/cjs" | ||
}, | ||
"include": [ | ||
"src", | ||
"test" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build-esm.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "dist/esm" | ||
}, | ||
"include": [ | ||
"src", | ||
"test" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "../../tsconfig.json" | ||
"extends": "../../tsconfig.esm.json" | ||
} |
Oops, something went wrong.