Skip to content

Commit

Permalink
Merge pull request #36 from golemfactory/feature/JST-785/esm-build
Browse files Browse the repository at this point in the history
JST-785: ESM build
  • Loading branch information
SewerynKras authored Mar 12, 2024
2 parents 0867126 + 7071c8e commit c6bd3a4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ jobs:
npm run build
npm install --prefix examples
npm run --prefix examples lint:ts
npm run test:import
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
npm run build
npm install --prefix examples
npm run --prefix examples lint:ts
npm run test:import
- name: Upload unit test reports
uses: actions/upload-artifact@v4
if: always()
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
"workspaces": [
"examples"
],
"type": "commonjs",
"main": "dist/task-executor.cjs.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/task-executor.mjs",
"require": "./dist/task-executor.cjs.js"
}
},
"browser": "dist/task-executor.min.js",
"module": "dist/task-executor.es.js",
"module": "dist/task-executor.mjs",
"types": "dist/index.d.ts",
"jsdelivr": "dist/task-executor.min.js",
"unpkg": "dist/task-executor.min.js",
Expand All @@ -37,6 +45,7 @@
"test:e2e": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config tests/e2e/jest.config.json tests/e2e/**.spec.ts --runInBand --forceExit",
"test:cypress": "cypress run",
"test:examples": "tsx tests/examples/examples.test.ts",
"test:import": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config tests/import/jest.config.js",
"lint": "npm run lint:ts && npm run lint:ts:tests && npm run lint:eslint",
"lint:ts": "tsc --project tsconfig.json --noEmit",
"lint:ts:tests": "tsc --project tests/tsconfig.json --noEmit",
Expand Down
6 changes: 6 additions & 0 deletions tests/import/import.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe("ESM Import", () => {
test("Import @golem-sdk/task-executor in ESM environment", async () => {
const { TaskExecutor } = await import("@golem-sdk/task-executor");
expect(typeof TaskExecutor).toBe("function");
});
});
9 changes: 9 additions & 0 deletions tests/import/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
verbose: true,
testEnvironment: "node",
// disable transforming source files because we want to execute the
// es modules directly
transform: {},
moduleFileExtensions: ["js", "cjs", "mjs"],
testMatch: ["**/?(*.)+(spec|test).mjs", "**/?(*.)+(spec|test).cjs"],
};
6 changes: 6 additions & 0 deletions tests/import/require.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe("CommonJS import", () => {
test("Require @golem-sdk/task-executor in CJS environment", async () => {
const { TaskExecutor } = require("@golem-sdk/task-executor");
expect(typeof TaskExecutor).toBe("function");
});
});

0 comments on commit c6bd3a4

Please sign in to comment.