diff --git a/etc/blocks/blob-url-custom-protocol/block/index.js b/etc/blocks/blob-url-custom-protocol/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/blob-url-custom-protocol/block/index.js +++ b/etc/blocks/blob-url-custom-protocol/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/blob-url-custom-protocol/block/package.json b/etc/blocks/blob-url-custom-protocol/block/package.json index 191313872c..f14c570408 100644 --- a/etc/blocks/blob-url-custom-protocol/block/package.json +++ b/etc/blocks/blob-url-custom-protocol/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-blob-url-custom-protocol", + "type": "module", "version": "1.0.63", "private": true, "scripts": { diff --git a/etc/blocks/blob-url-custom-protocol/model/package.json b/etc/blocks/blob-url-custom-protocol/model/package.json index e24dbb5ec3..6ce39e4935 100644 --- a/etc/blocks/blob-url-custom-protocol/model/package.json +++ b/etc/blocks/blob-url-custom-protocol/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/download-file/block/index.js b/etc/blocks/download-file/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/download-file/block/index.js +++ b/etc/blocks/download-file/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/download-file/block/package.json b/etc/blocks/download-file/block/package.json index 1a8b552de6..a94e0ad15d 100644 --- a/etc/blocks/download-file/block/package.json +++ b/etc/blocks/download-file/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-download-file", + "type": "module", "version": "1.0.127", "private": true, "scripts": { diff --git a/etc/blocks/download-file/model/package.json b/etc/blocks/download-file/model/package.json index 37d11575bc..76167c45bd 100644 --- a/etc/blocks/download-file/model/package.json +++ b/etc/blocks/download-file/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/enter-numbers-v3/block/index.js b/etc/blocks/enter-numbers-v3/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/enter-numbers-v3/block/index.js +++ b/etc/blocks/enter-numbers-v3/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/enter-numbers-v3/block/package.json b/etc/blocks/enter-numbers-v3/block/package.json index 170b34a960..5bc5ba1d7a 100644 --- a/etc/blocks/enter-numbers-v3/block/package.json +++ b/etc/blocks/enter-numbers-v3/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-enter-numbers-v3", + "type": "module", "version": "1.0.0", "private": true, "scripts": { diff --git a/etc/blocks/enter-numbers-v3/model/package.json b/etc/blocks/enter-numbers-v3/model/package.json index 940b3aee6b..f7e8e18453 100644 --- a/etc/blocks/enter-numbers-v3/model/package.json +++ b/etc/blocks/enter-numbers-v3/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/enter-numbers/block/index.js b/etc/blocks/enter-numbers/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/enter-numbers/block/index.js +++ b/etc/blocks/enter-numbers/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/enter-numbers/block/package.json b/etc/blocks/enter-numbers/block/package.json index a15cba1fa0..6dbfc8ff0c 100644 --- a/etc/blocks/enter-numbers/block/package.json +++ b/etc/blocks/enter-numbers/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-enter-numbers", + "type": "module", "version": "1.0.249", "private": true, "scripts": { diff --git a/etc/blocks/enter-numbers/model/package.json b/etc/blocks/enter-numbers/model/package.json index def16f8710..feade98b48 100644 --- a/etc/blocks/enter-numbers/model/package.json +++ b/etc/blocks/enter-numbers/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/model-test/block/index.js b/etc/blocks/model-test/block/index.js index 86fd78b422..79ec463f0f 100644 --- a/etc/blocks/model-test/block/index.js +++ b/etc/blocks/model-test/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', folder: __dirname, }; - -module.exports = { - blockSpec, - loadBlockDescription, -}; diff --git a/etc/blocks/model-test/block/package.json b/etc/blocks/model-test/block/package.json index dd942d34cd..b5d17683e6 100644 --- a/etc/blocks/model-test/block/package.json +++ b/etc/blocks/model-test/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-block-model", + "type": "module", "version": "1.0.167", "private": true, "scripts": { diff --git a/etc/blocks/model-test/model/package.json b/etc/blocks/model-test/model/package.json index 8ef2dd13bb..3561383849 100644 --- a/etc/blocks/model-test/model/package.json +++ b/etc/blocks/model-test/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/monetization-test/model/package.json b/etc/blocks/monetization-test/model/package.json index 1b628346a5..f3a8c99415 100644 --- a/etc/blocks/monetization-test/model/package.json +++ b/etc/blocks/monetization-test/model/package.json @@ -3,8 +3,7 @@ "version": "1.1.9", "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/monetization-test/workflow/index.js b/etc/blocks/monetization-test/workflow/index.js index 3dcb3faead..d2328b8ca2 100644 --- a/etc/blocks/monetization-test/workflow/index.js +++ b/etc/blocks/monetization-test/workflow/index.js @@ -1,5 +1,8 @@ -module.exports = { - Templates: { - main: { type: "from-file", path: require.resolve("./dist/tengo/tpl/main.plj.gz") }, - }, +import { fileURLToPath } from "node:url"; +import { dirname, resolve } from "node:path"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export const Templates = { + main: { type: "from-file", path: resolve(__dirname, "./dist/tengo/tpl/main.plj.gz") }, }; diff --git a/etc/blocks/pool-explorer/model/package.json b/etc/blocks/pool-explorer/model/package.json index dd057acb85..03d56fbdca 100644 --- a/etc/blocks/pool-explorer/model/package.json +++ b/etc/blocks/pool-explorer/model/package.json @@ -3,8 +3,7 @@ "version": "1.2.9", "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/read-logs/block/index.js b/etc/blocks/read-logs/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/read-logs/block/index.js +++ b/etc/blocks/read-logs/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/read-logs/block/package.json b/etc/blocks/read-logs/block/package.json index c21671a6a0..821200caf2 100644 --- a/etc/blocks/read-logs/block/package.json +++ b/etc/blocks/read-logs/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-read-logs", + "type": "module", "version": "1.0.127", "private": true, "scripts": { diff --git a/etc/blocks/read-logs/model/package.json b/etc/blocks/read-logs/model/package.json index aee62ee718..ae661ca3bd 100644 --- a/etc/blocks/read-logs/model/package.json +++ b/etc/blocks/read-logs/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/sum-numbers-v3/block/index.js b/etc/blocks/sum-numbers-v3/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/sum-numbers-v3/block/index.js +++ b/etc/blocks/sum-numbers-v3/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/sum-numbers-v3/block/package.json b/etc/blocks/sum-numbers-v3/block/package.json index 7c8bc17f95..b203b7ac6c 100644 --- a/etc/blocks/sum-numbers-v3/block/package.json +++ b/etc/blocks/sum-numbers-v3/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-sum-numbers-v3", + "type": "module", "version": "1.0.0", "private": true, "scripts": { diff --git a/etc/blocks/sum-numbers-v3/model/package.json b/etc/blocks/sum-numbers-v3/model/package.json index 13dd0a15f1..620065f430 100644 --- a/etc/blocks/sum-numbers-v3/model/package.json +++ b/etc/blocks/sum-numbers-v3/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/sum-numbers/block/index.js b/etc/blocks/sum-numbers/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/sum-numbers/block/index.js +++ b/etc/blocks/sum-numbers/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/sum-numbers/block/package.json b/etc/blocks/sum-numbers/block/package.json index c4aad90ed9..3eb11ff802 100644 --- a/etc/blocks/sum-numbers/block/package.json +++ b/etc/blocks/sum-numbers/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-sum-numbers", + "type": "module", "version": "1.0.127", "private": true, "scripts": { diff --git a/etc/blocks/sum-numbers/model/package.json b/etc/blocks/sum-numbers/model/package.json index 5969c532dd..dc2c1b0d39 100644 --- a/etc/blocks/sum-numbers/model/package.json +++ b/etc/blocks/sum-numbers/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/table-test/block/index.js b/etc/blocks/table-test/block/index.js index 86fd78b422..79ec463f0f 100644 --- a/etc/blocks/table-test/block/index.js +++ b/etc/blocks/table-test/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', folder: __dirname, }; - -module.exports = { - blockSpec, - loadBlockDescription, -}; diff --git a/etc/blocks/table-test/block/package.json b/etc/blocks/table-test/block/package.json index dcae43115c..914e5113c7 100644 --- a/etc/blocks/table-test/block/package.json +++ b/etc/blocks/table-test/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-block-table", + "type": "module", "version": "1.0.0", "private": true, "files": [ diff --git a/etc/blocks/table-test/model/package.json b/etc/blocks/table-test/model/package.json index 259c389f06..c57244e6aa 100644 --- a/etc/blocks/table-test/model/package.json +++ b/etc/blocks/table-test/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/transfer-files/block/index.js b/etc/blocks/transfer-files/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/transfer-files/block/index.js +++ b/etc/blocks/transfer-files/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/transfer-files/block/package.json b/etc/blocks/transfer-files/block/package.json index 99db4ef16f..0775111068 100644 --- a/etc/blocks/transfer-files/block/package.json +++ b/etc/blocks/transfer-files/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.transfer-files", + "type": "module", "version": "1.0.0", "private": true, "scripts": { diff --git a/etc/blocks/transfer-files/model/package.json b/etc/blocks/transfer-files/model/package.json index d1ae67718f..ac84e368dc 100644 --- a/etc/blocks/transfer-files/model/package.json +++ b/etc/blocks/transfer-files/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/ui-examples/block/index.js b/etc/blocks/ui-examples/block/index.js index 5166b019c3..79ec463f0f 100644 --- a/etc/blocks/ui-examples/block/index.js +++ b/etc/blocks/ui-examples/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname + folder: __dirname, }; - -module.exports = { - blockSpec, - loadBlockDescription -}; \ No newline at end of file diff --git a/etc/blocks/ui-examples/block/package.json b/etc/blocks/ui-examples/block/package.json index 4759749aed..5d228a2885 100644 --- a/etc/blocks/ui-examples/block/package.json +++ b/etc/blocks/ui-examples/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.ui-examples", + "type": "module", "version": "1.2.13", "scripts": { "build": "rm -rf ./block-pack && block-tools pack", diff --git a/etc/blocks/ui-examples/model/package.json b/etc/blocks/ui-examples/model/package.json index a02de0d4c5..1d3655470d 100644 --- a/etc/blocks/ui-examples/model/package.json +++ b/etc/blocks/ui-examples/model/package.json @@ -3,8 +3,7 @@ "version": "1.5.9", "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/etc/blocks/upload-file/block/index.js b/etc/blocks/upload-file/block/index.js index e7798d4206..79ec463f0f 100644 --- a/etc/blocks/upload-file/block/index.js +++ b/etc/blocks/upload-file/block/index.js @@ -1,15 +1,14 @@ -const blockTools = require('@platforma-sdk/block-tools'); +import { fileURLToPath } from 'node:url'; +import { dirname } from 'node:path'; +import * as blockTools from '@platforma-sdk/block-tools'; -async function loadBlockDescription() { +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export async function loadBlockDescription() { return await blockTools.loadPackDescriptionFromSource(__dirname); } -const blockSpec = { +export const blockSpec = { type: 'dev-v2', - folder: __dirname -}; - -module.exports = { - blockSpec, - loadBlockDescription + folder: __dirname, }; diff --git a/etc/blocks/upload-file/block/package.json b/etc/blocks/upload-file/block/package.json index 9bc1f9db95..5acb15fa3c 100644 --- a/etc/blocks/upload-file/block/package.json +++ b/etc/blocks/upload-file/block/package.json @@ -1,5 +1,6 @@ { "name": "@milaboratories/milaboratories.test-upload-file", + "type": "module", "version": "1.0.127", "private": true, "scripts": { diff --git a/etc/blocks/upload-file/model/package.json b/etc/blocks/upload-file/model/package.json index 6a171f6e62..4129bc90a2 100644 --- a/etc/blocks/upload-file/model/package.json +++ b/etc/blocks/upload-file/model/package.json @@ -4,8 +4,7 @@ "private": true, "description": "Block model", "type": "module", - "main": "dist/index.cjs", - "module": "dist/index.js", + "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "ts-builder build --target block-model && block-tools build-model", diff --git a/lib/model/backend/package.json b/lib/model/backend/package.json index 6ed22097af..c1d81f4993 100644 --- a/lib/model/backend/package.json +++ b/lib/model/backend/package.json @@ -7,14 +7,12 @@ "./src/**/*" ], "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/model/common/package.json b/lib/model/common/package.json index f0e642b3af..df209d78c1 100644 --- a/lib/model/common/package.json +++ b/lib/model/common/package.json @@ -12,8 +12,7 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/model/middle-layer/package.json b/lib/model/middle-layer/package.json index a74f6afb21..d0b65c3c40 100644 --- a/lib/model/middle-layer/package.json +++ b/lib/model/middle-layer/package.json @@ -12,8 +12,7 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/model/pf-spec-driver/package.json b/lib/model/pf-spec-driver/package.json index 0ae3ffd788..71576d51f0 100644 --- a/lib/model/pf-spec-driver/package.json +++ b/lib/model/pf-spec-driver/package.json @@ -10,13 +10,11 @@ ], "type": "module", "main": "./dist/index.js", - "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/model/pl-error-like/package.json b/lib/model/pl-error-like/package.json index 5cf3b5c5be..b0b20a88f6 100644 --- a/lib/model/pl-error-like/package.json +++ b/lib/model/pl-error-like/package.json @@ -6,14 +6,13 @@ "./dist/**/*", "./src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/node/computable/package.json b/lib/node/computable/package.json index ed92b32ce8..fe7fcd48d5 100644 --- a/lib/node/computable/package.json +++ b/lib/node/computable/package.json @@ -6,13 +6,12 @@ "./dist/**/*", "./src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/node-streams/package.json b/lib/node/node-streams/package.json index 10d573abbe..95b9bd7a7f 100644 --- a/lib/node/node-streams/package.json +++ b/lib/node/node-streams/package.json @@ -6,14 +6,13 @@ "./dist/**/*", "./src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/node/pf-driver/package.json b/lib/node/pf-driver/package.json index d88ca42ac1..8578c70b0b 100644 --- a/lib/node/pf-driver/package.json +++ b/lib/node/pf-driver/package.json @@ -10,13 +10,11 @@ ], "type": "module", "main": "./dist/index.js", - "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/node/pl-client/package.json b/lib/node/pl-client/package.json index e98930a6ce..245c6767ab 100644 --- a/lib/node/pl-client/package.json +++ b/lib/node/pl-client/package.json @@ -7,13 +7,11 @@ "./src/**/*" ], "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/pl-config/package.json b/lib/node/pl-config/package.json index 8959e9af58..fa497628bf 100644 --- a/lib/node/pl-config/package.json +++ b/lib/node/pl-config/package.json @@ -14,13 +14,12 @@ "assets", "postinstall.js" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/pl-deployments/package.json b/lib/node/pl-deployments/package.json index d36533a3b7..cb6ca0c63a 100644 --- a/lib/node/pl-deployments/package.json +++ b/lib/node/pl-deployments/package.json @@ -13,13 +13,12 @@ "assets", "postinstall.js" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/pl-errors/package.json b/lib/node/pl-errors/package.json index 1be8e3a33a..a3f171d333 100644 --- a/lib/node/pl-errors/package.json +++ b/lib/node/pl-errors/package.json @@ -6,13 +6,12 @@ "./dist/**/*", "./src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/pl-http/package.json b/lib/node/pl-http/package.json index 562ae9822e..3d74e09f14 100644 --- a/lib/node/pl-http/package.json +++ b/lib/node/pl-http/package.json @@ -7,13 +7,11 @@ "./src/**/*" ], "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/pl-tree/package.json b/lib/node/pl-tree/package.json index 58d89eca36..2995cae6c7 100644 --- a/lib/node/pl-tree/package.json +++ b/lib/node/pl-tree/package.json @@ -6,13 +6,12 @@ "./dist/**/*", "./src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/resolve-helper/.oxfmtrc.json b/lib/node/resolve-helper/.oxfmtrc.json new file mode 100644 index 0000000000..7eff5e7af0 --- /dev/null +++ b/lib/node/resolve-helper/.oxfmtrc.json @@ -0,0 +1,4 @@ +{ + "extends": ["node_modules/@milaboratories/ts-builder/configs/oxfmt.json"], + "ignorePatterns": ["dist", "coverage", "CHANGELOG.md"] +} diff --git a/lib/node/resolve-helper/.oxlintrc.json b/lib/node/resolve-helper/.oxlintrc.json new file mode 100644 index 0000000000..b1a139038f --- /dev/null +++ b/lib/node/resolve-helper/.oxlintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["node_modules/@milaboratories/ts-builder/dist/configs/oxlint-node.json"] +} diff --git a/lib/node/resolve-helper/package.json b/lib/node/resolve-helper/package.json index 4fcaaa3416..393580f9b8 100644 --- a/lib/node/resolve-helper/package.json +++ b/lib/node/resolve-helper/package.json @@ -2,24 +2,39 @@ "name": "@milaboratories/resolve-helper", "version": "1.1.3", "description": "Helper functions to resolve packages in a ESM / CJS independent manner", - "types": "./src/index.d.ts", - "main": "./src/index.js", - "module": "./src/index.mjs", + "license": "UNLICENSED", + "files": [ + "./dist/**/*", + "./src/**/*" + ], + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": { - "types": "./src/index.d.ts", - "require": "./src/index.js", - "import": "./src/index.mjs" + "types": "./dist/index.d.ts", + "sources": "./src/index.ts", + "import": "./dist/index.js" } }, - "files": [ - "src/**/*" - ], - "license": "UNLICENSED", - "scripts": {}, + "scripts": { + "build": "ts-builder build --target node", + "watch": "ts-builder build --target node --watch", + "check": "ts-builder check --target node", + "formatter:check": "ts-builder formatter --check", + "linter:check": "ts-builder linter --check", + "types:check": "ts-builder type-check --target node", + "do-pack": "rm -f *.tgz && pnpm pack && mv *.tgz package.tgz", + "fmt": "ts-builder format" + }, "devDependencies": { "@milaboratories/build-configs": "workspace:*", + "@milaboratories/ts-builder": "workspace:*", "@milaboratories/ts-configs": "workspace:*", + "@types/node": "catalog:", "typescript": "catalog:" + }, + "engines": { + "node": ">=22" } -} \ No newline at end of file +} diff --git a/lib/node/resolve-helper/src/index.d.ts b/lib/node/resolve-helper/src/index.d.ts deleted file mode 100644 index 9a6f8ff2b8..0000000000 --- a/lib/node/resolve-helper/src/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type ResolveError = "MODULE_NOT_FOUND" | "ERR_PACKAGE_PATH_NOT_EXPORTED"; - -export type ResolveResultOrError = { - result: string; -} | { - result?: undefined; - err: ResolveError; -} - -export declare function tryResolveOrError(root: string, request: string): ResolveResultOrError; -export declare function tryResolve(root: string, request: string): string | undefined; diff --git a/lib/node/resolve-helper/src/index.js b/lib/node/resolve-helper/src/index.js deleted file mode 100644 index 979815302f..0000000000 --- a/lib/node/resolve-helper/src/index.js +++ /dev/null @@ -1,21 +0,0 @@ -function tryResolveOrError(root, request) { - try { - const result = require.resolve(request, { - paths: [root] - }); - return { result }; - } catch (err) { - if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw err; - return { err: err.code }; - } -} - -function tryResolve(root, request) { - const result = tryResolveOrError(root, request); - return result.result; -} - -module.exports = { - tryResolve, - tryResolveOrError -}; diff --git a/lib/node/resolve-helper/src/index.mjs b/lib/node/resolve-helper/src/index.mjs deleted file mode 100644 index d1c68afec4..0000000000 --- a/lib/node/resolve-helper/src/index.mjs +++ /dev/null @@ -1,19 +0,0 @@ -import { createRequire } from 'node:module'; - -export function tryResolveOrError(root, request) { - try { - const require = createRequire(import.meta.url); - const result = require.resolve(request, { - paths: [root] - }); - return { result }; - } catch (err) { - if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw err; - return { err: err.code }; - } -} - -export function tryResolve(root, request) { - const result = tryResolveOrError(root, request); - return result.result; -} diff --git a/lib/node/resolve-helper/src/index.ts b/lib/node/resolve-helper/src/index.ts new file mode 100644 index 0000000000..a513ef8eef --- /dev/null +++ b/lib/node/resolve-helper/src/index.ts @@ -0,0 +1,222 @@ +import { createRequire, findPackageJSON } from "node:module"; +import { pathToFileURL } from "node:url"; +import * as path from "node:path"; +import * as fs from "node:fs"; + +export type ResolveError = "MODULE_NOT_FOUND" | "ERR_PACKAGE_PATH_NOT_EXPORTED"; + +export type ResolveResultOrError = + | { + result: string; + err?: undefined; + } + | { + result?: undefined; + err: ResolveError; + }; + +function rootToParentURL(root: string): string { + // Use a dummy filename inside `root` as the "parent" for resolution. + // Node treats it as a file URL even if the file doesn't exist, which + // is exactly what the built-in resolver needs. + return pathToFileURL(path.join(root, "index.js")).href; +} + +/** + * Resolve an ESM-only package subpath via `import.meta.resolve`-equivalent + * logic. Returns a file path on success, or an error code on failure. + * + * Node does not expose a synchronous ESM resolver for arbitrary parent URLs + * in stable form, so we approximate it using `findPackageJSON` + manual + * subpath/exports interpretation. This is enough for the common cases used + * across this codebase: resolving a package main entry, `pkg/package.json`, + * or a package subpath. + */ +function esmResolve(root: string, request: string): ResolveResultOrError { + const parent = rootToParentURL(root); + let pkgJsonPath: string | undefined; + try { + pkgJsonPath = findPackageJSON(request, parent); + } catch { + return { err: "MODULE_NOT_FOUND" }; + } + if (!pkgJsonPath) return { err: "MODULE_NOT_FOUND" }; + + const pkgDir = path.dirname(pkgJsonPath); + + // Parse the package name out of the request so we know what the subpath is. + // Supports both scoped ("@scope/name/sub") and unscoped ("name/sub"). + let pkgName: string; + let subpath: string; + if (request.startsWith("@")) { + const firstSlash = request.indexOf("/"); + if (firstSlash === -1) return { err: "MODULE_NOT_FOUND" }; + const secondSlash = request.indexOf("/", firstSlash + 1); + if (secondSlash === -1) { + pkgName = request; + subpath = "."; + } else { + pkgName = request.slice(0, secondSlash); + subpath = "." + request.slice(secondSlash); + } + } else { + const firstSlash = request.indexOf("/"); + if (firstSlash === -1) { + pkgName = request; + subpath = "."; + } else { + pkgName = request.slice(0, firstSlash); + subpath = "." + request.slice(firstSlash); + } + } + + // Special-case: "package.json" subpath is always the found package.json + // even when not listed in `exports` (mirrors Node's historical behaviour). + if (subpath === "./package.json") { + return { result: pkgJsonPath }; + } + + let pkg: Record; + try { + pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8")) as Record; + } catch { + return { err: "MODULE_NOT_FOUND" }; + } + + if (pkg.name !== pkgName) { + // findPackageJSON returned a parent package.json (e.g. when scanning a + // workspace). Treat as not found. + return { err: "MODULE_NOT_FOUND" }; + } + + const exportsField = pkg.exports; + if (exportsField !== undefined && exportsField !== null) { + const target = matchExports(exportsField, subpath); + if (target === null) return { err: "ERR_PACKAGE_PATH_NOT_EXPORTED" }; + if (target === undefined) return { err: "MODULE_NOT_FOUND" }; + return { result: path.resolve(pkgDir, target) }; + } + + // No `exports` field — fall back to `main` / subpath. + if (subpath === ".") { + const main = typeof pkg.main === "string" ? pkg.main : "index.js"; + return { result: path.resolve(pkgDir, main) }; + } + return { result: path.resolve(pkgDir, subpath) }; +} + +type ExportsValue = string | null | { [key: string]: ExportsValue } | ExportsValue[]; + +const CONDITIONS = ["node", "import", "default"]; + +function matchExports(exportsField: unknown, subpath: string): string | null | undefined { + // String form: only valid for "." subpath. + if (typeof exportsField === "string") { + return subpath === "." ? exportsField : undefined; + } + if (exportsField === null) return null; + if (Array.isArray(exportsField)) { + for (const entry of exportsField) { + const res = matchExports(entry, subpath); + if (res !== undefined) return res; + } + return undefined; + } + if (typeof exportsField !== "object") return undefined; + + const obj = exportsField as Record; + const keys = Object.keys(obj); + const looksLikeSubpathMap = keys.length > 0 && keys.every((k) => k.startsWith(".")); + + if (looksLikeSubpathMap) { + // Exact match first. + if (subpath in obj) { + return resolveConditions(obj[subpath], subpath); + } + // Pattern match (wildcards / trailing-slash). Keep it simple — we only + // handle the most common cases. + for (const key of keys) { + if (key.endsWith("/") && subpath.startsWith(key)) { + const rest = subpath.slice(key.length); + const resolved = resolveConditions(obj[key], subpath); + if (resolved === null || resolved === undefined) return resolved; + return resolved + rest; + } + if (key.includes("*")) { + const [prefix, suffix] = key.split("*"); + if (subpath.startsWith(prefix) && subpath.endsWith(suffix ?? "")) { + const middle = subpath.slice(prefix.length, subpath.length - (suffix?.length ?? 0)); + const target = resolveConditions(obj[key], subpath); + if (typeof target !== "string") return target; + return target.replace("*", middle); + } + } + } + return subpath === "." ? undefined : null; + } + + // Conditional-only map (no subpaths). Only valid for "." subpath. + if (subpath !== ".") return undefined; + return resolveConditions(exportsField as ExportsValue, subpath); +} + +// oxlint-disable-next-line oxc/only-used-in-recursion +function resolveConditions(value: ExportsValue, subpath: string): string | null | undefined { + if (typeof value === "string" || value === null) return value; + if (Array.isArray(value)) { + for (const entry of value) { + const res = resolveConditions(entry, subpath); + if (res !== undefined) return res; + } + return undefined; + } + if (typeof value !== "object") return undefined; + const obj = value as Record; + for (const cond of CONDITIONS) { + if (cond in obj) { + const res = resolveConditions(obj[cond], subpath); + if (res !== undefined) return res; + } + } + if ("default" in obj) return resolveConditions(obj.default, subpath); + return undefined; +} + +const selfRequire = createRequire(import.meta.url); + +function cjsResolve(root: string, request: string): ResolveResultOrError { + try { + const result = selfRequire.resolve(request, { paths: [root] }); + return { result }; + } catch (err: unknown) { + const code = (err as NodeJS.ErrnoException | undefined)?.code; + if (code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED") { + return { err: code }; + } + throw err; + } +} + +export function tryResolveOrError(root: string, request: string): ResolveResultOrError { + // Fast path: CJS resolver. Works for any package that exposes a `require` + // or unconditional entry. + const cjs = cjsResolve(root, request); + if (cjs.result !== undefined) return cjs; + + // Fallback: ESM-aware resolution for packages that only publish `import` + // conditionals (pure-ESM packages). + const esm = esmResolve(root, request); + if (esm.result !== undefined) return esm; + + // Prefer ERR_PACKAGE_PATH_NOT_EXPORTED over MODULE_NOT_FOUND if either + // resolver reports it — callers rely on this code to distinguish the two + // failure modes. + if (cjs.err === "ERR_PACKAGE_PATH_NOT_EXPORTED" || esm.err === "ERR_PACKAGE_PATH_NOT_EXPORTED") { + return { err: "ERR_PACKAGE_PATH_NOT_EXPORTED" }; + } + return { err: "MODULE_NOT_FOUND" }; +} + +export function tryResolve(root: string, request: string): string | undefined { + return tryResolveOrError(root, request).result; +} diff --git a/lib/node/resolve-helper/tsconfig.json b/lib/node/resolve-helper/tsconfig.json index eace7aba90..cf8968064b 100644 --- a/lib/node/resolve-helper/tsconfig.json +++ b/lib/node/resolve-helper/tsconfig.json @@ -1,11 +1,5 @@ { "extends": "@milaboratories/ts-configs/tsconfig.node.json", - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "dist", - "build" - ] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"] } diff --git a/lib/node/ts-helpers-oclif/package.json b/lib/node/ts-helpers-oclif/package.json index 5c221f3817..44ecd4594c 100644 --- a/lib/node/ts-helpers-oclif/package.json +++ b/lib/node/ts-helpers-oclif/package.json @@ -6,13 +6,12 @@ "dist/**/*", "src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/ts-helpers-winston/package.json b/lib/node/ts-helpers-winston/package.json index e421438f95..d3f20d8cd9 100644 --- a/lib/node/ts-helpers-winston/package.json +++ b/lib/node/ts-helpers-winston/package.json @@ -6,13 +6,12 @@ "dist/**/*", "src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/node/ts-helpers/package.json b/lib/node/ts-helpers/package.json index 3780c3fe0c..0568532b8b 100644 --- a/lib/node/ts-helpers/package.json +++ b/lib/node/ts-helpers/package.json @@ -7,13 +7,11 @@ "./src/**/*" ], "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/other/biowasm-tools/package.json b/lib/other/biowasm-tools/package.json index 273120a917..4ab4be12fa 100644 --- a/lib/other/biowasm-tools/package.json +++ b/lib/other/biowasm-tools/package.json @@ -4,6 +4,7 @@ "files": [ "dist" ], + "type": "module", "exports": { "./kalign": { "types": "./dist/kalign.d.ts", diff --git a/lib/ptabler/js/package.json b/lib/ptabler/js/package.json index 6af7ec964a..dcb0d2ac9e 100644 --- a/lib/ptabler/js/package.json +++ b/lib/ptabler/js/package.json @@ -12,8 +12,7 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/lib/ptabler/schema/package.json b/lib/ptabler/schema/package.json index 143e1414fd..fae17dcc42 100644 --- a/lib/ptabler/schema/package.json +++ b/lib/ptabler/schema/package.json @@ -6,14 +6,13 @@ "./dist/**/*", "./src/**/*" ], + "type": "module", "main": "./dist/index.js", - "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.js" + "import": "./dist/index.mjs" } }, "scripts": { diff --git a/lib/ptabler/schema/vite.config.mts b/lib/ptabler/schema/vite.config.mts index a4867d571c..9be866a1cb 100644 --- a/lib/ptabler/schema/vite.config.mts +++ b/lib/ptabler/schema/vite.config.mts @@ -7,7 +7,7 @@ export default defineConfig({ lib: { entry: resolve("src", "index.ts"), fileName: "index", - formats: ["es", "cjs"], + formats: ["es"], }, sourcemap: true, rolldownOptions: {}, diff --git a/lib/ptabler/software/package.json b/lib/ptabler/software/package.json index 92f9e2bfc1..17b161230e 100644 --- a/lib/ptabler/software/package.json +++ b/lib/ptabler/software/package.json @@ -1,6 +1,7 @@ { "name": "@platforma-open/milaboratories.software-ptabler", "version": "1.15.0", + "type": "module", "scripts": { "init-python:create-venv": "mise exec python@3.12.10 -- python -m venv --clear .venv", "init-python:pip-install": ".venv/bin/pip install --quiet --disable-pip-version-check", diff --git a/lib/ptexter/package.json b/lib/ptexter/package.json index b2a034ea16..0304b57f9b 100644 --- a/lib/ptexter/package.json +++ b/lib/ptexter/package.json @@ -2,6 +2,7 @@ "name": "@platforma-open/milaboratories.software-ptexter", "version": "1.2.2", "description": "Text processing utilities for platforma", + "type": "module", "scripts": { "build": "rm -rf ./dist && pl-pkg build", "prepublishOnly": "pl-pkg prepublish", diff --git a/lib/util/helpers/package.json b/lib/util/helpers/package.json index 12138915f2..0a501137ef 100644 --- a/lib/util/helpers/package.json +++ b/lib/util/helpers/package.json @@ -13,7 +13,6 @@ ".": { "types": "./dist/index.d.ts", "sources": "./src/index.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/util/sequences/package.json b/lib/util/sequences/package.json index 61ce2922bc..23c5e73b68 100644 --- a/lib/util/sequences/package.json +++ b/lib/util/sequences/package.json @@ -5,13 +5,12 @@ "./dist/**/*", "./src/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/lib/util/test-helpers/package.json b/lib/util/test-helpers/package.json index 7b9deb79c0..c9e5213d0a 100644 --- a/lib/util/test-helpers/package.json +++ b/lib/util/test-helpers/package.json @@ -13,7 +13,6 @@ ".": { "types": "./dist/index.d.ts", "sources": "./src/index.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec55c7ec94..1382bc7b11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,9 +66,6 @@ catalogs: '@protobuf-ts/runtime-rpc': specifier: 2.11.1 version: 2.11.1 - '@rollup/plugin-node-resolve': - specifier: ^16.0.1 - version: 16.0.1 '@types/d3-array': specifier: ^3.2.1 version: 3.2.1 @@ -2438,9 +2435,15 @@ importers: '@milaboratories/build-configs': specifier: workspace:* version: link:../../../tools/build-configs + '@milaboratories/ts-builder': + specifier: workspace:* + version: link:../../../tools/ts-builder '@milaboratories/ts-configs': specifier: workspace:* version: link:../../../tools/ts-configs + '@types/node': + specifier: 'catalog:' + version: 24.5.2 typescript: specifier: 'catalog:' version: 5.9.3 @@ -3426,9 +3429,6 @@ importers: '@milaboratories/ts-configs': specifier: workspace:* version: link:../ts-configs - '@rollup/plugin-node-resolve': - specifier: 'catalog:' - version: 16.0.1(rollup@4.60.1) '@types/mime-types': specifier: 'catalog:' version: 2.1.4 @@ -3444,21 +3444,12 @@ importers: oclif: specifier: 'catalog:' version: 4.16.2(@types/node@24.5.2) - rollup-plugin-node-externals: - specifier: 'catalog:' - version: 8.0.0(rollup@4.60.1) semver: specifier: 'catalog:' version: 7.7.2 typescript: specifier: 'catalog:' version: 5.9.3 - vite: - specifier: 'catalog:' - version: 8.0.6(@types/node@24.5.2)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.83.4)(tsx@4.19.1)(yaml@2.8.0) - vite-plugin-dts: - specifier: 'catalog:' - version: 4.5.3(@types/node@24.5.2)(rollup@4.60.1)(typescript@5.9.3)(vite@8.0.6(@types/node@24.5.2)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.83.4)(tsx@4.19.1)(yaml@2.8.0)) vitest: specifier: 'catalog:' version: 4.1.3(@types/node@24.5.2)(@vitest/coverage-istanbul@4.1.3)(happy-dom@15.11.7)(jsdom@25.0.1)(vite@8.0.6(@types/node@24.5.2)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.83.4)(tsx@4.19.1)(yaml@2.8.0)) @@ -5444,15 +5435,6 @@ packages: '@rolldown/pluginutils@1.0.0-rc.2': resolution: {integrity: sha512-izyXV/v+cHiRfozX62W9htOAvwMo4/bXKDrQ+vom1L1qRuexPock/7VZDAhnpHCLNejd3NJ6hiab+tO0D44Rgw==} - '@rollup/plugin-node-resolve@16.0.1': - resolution: {integrity: sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^2.78.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - '@rollup/pluginutils@5.1.4': resolution: {integrity: sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==} engines: {node: '>=14.0.0'} @@ -6098,9 +6080,6 @@ packages: '@types/readline-sync@1.4.8': resolution: {integrity: sha512-BL7xOf0yKLA6baAX6MMOnYkoflUyj/c7y3pqMRfU0va7XlwHAOTOIo4x55P/qLfMsuaYdJJKubToLqRVmRtRZA==} - '@types/resolve@1.20.2': - resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} - '@types/semver@7.7.0': resolution: {integrity: sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA==} @@ -6907,10 +6886,6 @@ packages: babel-plugin-macros: optional: true - deepmerge@4.3.1: - resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} - engines: {node: '>=0.10.0'} - defer-to-connect@2.0.1: resolution: {integrity: sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==} engines: {node: '>=10'} @@ -7537,9 +7512,6 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} - is-module@1.0.0: - resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} - is-natural-number@4.0.1: resolution: {integrity: sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==} @@ -11553,16 +11525,6 @@ snapshots: '@rolldown/pluginutils@1.0.0-rc.2': {} - '@rollup/plugin-node-resolve@16.0.1(rollup@4.60.1)': - dependencies: - '@rollup/pluginutils': 5.1.4(rollup@4.60.1) - '@types/resolve': 1.20.2 - deepmerge: 4.3.1 - is-module: 1.0.0 - resolve: 1.22.8 - optionalDependencies: - rollup: 4.60.1 - '@rollup/pluginutils@5.1.4(rollup@4.60.1)': dependencies: '@types/estree': 1.0.8 @@ -12392,8 +12354,6 @@ snapshots: '@types/readline-sync@1.4.8': {} - '@types/resolve@1.20.2': {} - '@types/semver@7.7.0': {} '@types/sortablejs@1.15.8': {} @@ -13305,8 +13265,6 @@ snapshots: dedent@1.7.0: {} - deepmerge@4.3.1: {} - defer-to-connect@2.0.1: {} delayed-stream@1.0.0: {} @@ -13988,8 +13946,6 @@ snapshots: dependencies: is-extglob: 2.1.1 - is-module@1.0.0: {} - is-natural-number@4.0.1: {} is-number@7.0.0: {} diff --git a/sdk/model/package.json b/sdk/model/package.json index 2b0e56be26..742048bc19 100644 --- a/sdk/model/package.json +++ b/sdk/model/package.json @@ -14,14 +14,12 @@ ".": { "types": "./dist/index.d.ts", "sources": "./src/index.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" }, "./render/internal": { "types": "./dist/render/internal.d.ts", "sources": "./src/render/internal.ts", - "import": "./dist/render/internal.js", - "require": "./dist/render/internal.cjs" + "import": "./dist/render/internal.js" } }, "scripts": { diff --git a/sdk/test/package.json b/sdk/test/package.json index e488c5e422..6a754d9d16 100644 --- a/sdk/test/package.json +++ b/sdk/test/package.json @@ -6,13 +6,12 @@ "files": [ "dist/**/*" ], - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "type": "module", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/sdk/workflow-tengo/package.json b/sdk/workflow-tengo/package.json index b20730ae0c..c2a0ea1654 100644 --- a/sdk/workflow-tengo/package.json +++ b/sdk/workflow-tengo/package.json @@ -8,8 +8,7 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "files": [ diff --git a/tests/workflow-tengo/package.json b/tests/workflow-tengo/package.json index 86c75dd5ad..d743df4669 100644 --- a/tests/workflow-tengo/package.json +++ b/tests/workflow-tengo/package.json @@ -9,7 +9,6 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/tools/block-tools/bin/run.js b/tools/block-tools/bin/run.js index 788bfa812b..36da6d77ff 100755 --- a/tools/block-tools/bin/run.js +++ b/tools/block-tools/bin/run.js @@ -1,5 +1,10 @@ #!/usr/bin/env node +import { fileURLToPath } from "node:url"; +import { dirname } from "node:path"; +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + // eslint-disable-next-line unicorn/prefer-top-level-await (async () => { const oclif = await import("@oclif/core"); diff --git a/tools/block-tools/build.node.config.js b/tools/block-tools/build.node.config.js new file mode 100644 index 0000000000..5789008a82 --- /dev/null +++ b/tools/block-tools/build.node.config.js @@ -0,0 +1,5 @@ +import { createRolldownNodeConfig } from "@milaboratories/ts-builder/configs/utils/createRolldownNodeConfig.js"; + +export default createRolldownNodeConfig({ + entry: ["src/cmd/index.ts", "src/index.ts"], +}); diff --git a/tools/block-tools/package.json b/tools/block-tools/package.json index 325f50382a..fcf59c5aa9 100644 --- a/tools/block-tools/package.json +++ b/tools/block-tools/package.json @@ -12,20 +12,19 @@ "./src/**/*", "./README.md" ], + "type": "module", "main": "./dist/index.js", - "module": "./dist/index.mjs", "types": "./dist/lib.d.ts", "exports": { ".": { "types": "./dist/lib.d.ts", - "require": "./dist/index.js", - "import": "./dist/index.mjs" + "default": "./dist/index.js" } }, "scripts": { "oclif:index": "oclif-index --commands-root=./src/cmd/ --index-file=./src/cmd/index.ts && node --run fmt", - "build": "vite build", "readme": "oclif readme", + "build": "ts-builder build --target node --build-config ./build.node.config.js", "test": "vitest run --coverage", "do-pack": "rm -f *.tgz && pnpm pack && mv *.tgz package.tgz", "formatter:check": "ts-builder formatter --check", @@ -57,17 +56,13 @@ "@milaboratories/oclif-index": "workspace:*", "@milaboratories/ts-builder": "workspace:*", "@milaboratories/ts-configs": "workspace:*", - "@rollup/plugin-node-resolve": "catalog:", "@types/mime-types": "catalog:", "@types/node": "catalog:", "@types/semver": "catalog:", "@vitest/coverage-istanbul": "catalog:", "oclif": "catalog:", - "rollup-plugin-node-externals": "catalog:", "semver": "catalog:", "typescript": "catalog:", - "vite": "catalog:", - "vite-plugin-dts": "catalog:", "vitest": "catalog:" }, "oclif": { @@ -75,7 +70,7 @@ "commands": { "identifier": "COMMANDS", "strategy": "explicit", - "target": "./dist/cli.js" + "target": "./dist/cmd/index.js" }, "dirname": "block-tools", "topicSeparator": " " diff --git a/tools/block-tools/src/cmd/build-model.ts b/tools/block-tools/src/cmd/build-model.ts index a6a8c2b42c..d220df3771 100644 --- a/tools/block-tools/src/cmd/build-model.ts +++ b/tools/block-tools/src/cmd/build-model.ts @@ -1,6 +1,8 @@ import { Command, Flags } from "@oclif/core"; import fs from "node:fs"; +import { createRequire } from "node:module"; import path from "node:path"; +import { pathToFileURL } from "node:url"; async function getFileContent(path: string) { try { @@ -43,8 +45,10 @@ export default class BuildModel extends Command { public async run(): Promise { const { flags } = await this.parse(BuildModel); const modulePath = path.resolve(flags.modulePath); // i.e. folder with package.json file + const require = createRequire(import.meta.url); + const resolved = require.resolve(modulePath); // eslint-disable-next-line prefer-const, @typescript-eslint/no-unsafe-assignment - let { model, platforma } = require(modulePath); + let { model, platforma } = await import(pathToFileURL(resolved).href); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment if (!model) model = platforma; diff --git a/tools/block-tools/src/lib.ts b/tools/block-tools/src/index.ts similarity index 100% rename from tools/block-tools/src/lib.ts rename to tools/block-tools/src/index.ts diff --git a/tools/block-tools/src/v2/registry/registry.ts b/tools/block-tools/src/v2/registry/registry.ts index e27a3e1cc4..4626c0b79a 100644 --- a/tools/block-tools/src/v2/registry/registry.ts +++ b/tools/block-tools/src/v2/registry/registry.ts @@ -21,8 +21,9 @@ import { globalOverviewSnapshotPath, packageOverviewSnapshotPath, } from "./schema_internal"; +import type { GlobalOverviewReg } from "./schema_public"; import { - GlobalOverviewReg, + parseGlobalOverviewReg, GlobalOverviewPath, GlobalOverviewGzPath, ManifestSuffix, @@ -184,7 +185,7 @@ export class BlockRegistryV2 { ? { schema: "v2", packages: [] } : overviewContent === undefined ? { schema: "v2", packages: [] } - : GlobalOverviewReg.parse(JSON.parse(overviewContent.toString())); + : parseGlobalOverviewReg(JSON.parse(overviewContent.toString())); let overviewPackages = overview.packages; this.logger.info( `Global overview ${mode === "force" ? "starting empty (force mode)" : "loaded"}, ${overviewPackages.length} records`, @@ -381,7 +382,7 @@ export class BlockRegistryV2 { public async getGlobalOverview(): Promise { const content = await this.storage.getFile(GlobalOverviewPath); if (content === undefined) return undefined; - return GlobalOverviewReg.parse(JSON.parse(content.toString())); + return parseGlobalOverviewReg(JSON.parse(content.toString())); } private async marchChanged(id: BlockPackId) { @@ -456,7 +457,7 @@ export class BlockRegistryV2 { // Validate the data try { - GlobalOverviewReg.parse(JSON.parse(overviewData)); + parseGlobalOverviewReg(JSON.parse(overviewData)); } catch (error) { throw new Error(`Invalid snapshot data in ${backupId}: ${String(error)}`); } diff --git a/tools/block-tools/src/v2/registry/registry_reader.ts b/tools/block-tools/src/v2/registry/registry_reader.ts index b8d5c0a46b..13a6e09c19 100644 --- a/tools/block-tools/src/v2/registry/registry_reader.ts +++ b/tools/block-tools/src/v2/registry/registry_reader.ts @@ -16,11 +16,11 @@ import type { FolderReader } from "../../io"; import canonicalize from "canonicalize"; import { GlobalOverviewFileName, - GlobalOverviewReg, MainPrefix, ManifestFileName, ManifestSuffix, packageContentPrefixInsideV2, + parseGlobalOverviewReg, } from "./schema_public"; import { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from "../model"; import { LRUCache } from "lru-cache"; @@ -121,7 +121,7 @@ export class RegistryV2Reader { try { return await retry(async () => { // const rootContentReader = this.v2RootFolderReader.getContentReader(); - const globalOverview = GlobalOverviewReg.parse( + const globalOverview = parseGlobalOverviewReg( JSON.parse( Buffer.from(await this.v2RootFolderReader.readFile(GlobalOverviewFileName)).toString(), ), diff --git a/tools/block-tools/src/v2/registry/schema_public.ts b/tools/block-tools/src/v2/registry/schema_public.ts index e4610afa24..baef4b82bc 100644 --- a/tools/block-tools/src/v2/registry/schema_public.ts +++ b/tools/block-tools/src/v2/registry/schema_public.ts @@ -1,19 +1,10 @@ -import type { BlockPackId } from "@milaboratories/pl-model-middle-layer"; +import type { BlockPackId, BlockPackIdNoVersion } from "@milaboratories/pl-model-middle-layer"; import { AnyChannel, - BlockComponentsManifest, BlockPackDescriptionManifest, - BlockPackIdNoVersion, - BlockPackMeta, - ContentRelativeBinary, - ContentRelativeText, - CreateBlockPackDescriptionSchema, Sha256Schema, - VersionWithChannels, } from "@milaboratories/pl-model-middle-layer"; import { z } from "zod"; -import type { RelativeContentReader } from "../model"; -import { relativeToExplicitBytes, relativeToExplicitString } from "../model"; export const MainPrefix = "v2/"; @@ -79,106 +70,60 @@ export const PackageManifestPattern = export const GlobalOverviewPath = `${MainPrefix}${GlobalOverviewFileName}`; export const GlobalOverviewGzPath = `${MainPrefix}${GlobalOverviewGzFileName}`; -export function GlobalOverviewEntry( - descriptionType: Description, -) { - const universalSchema = z - .object({ - id: BlockPackIdNoVersion, - /** @deprecated to be removed at some point, not used, left for compatibility with older versions */ - allVersions: z.array(z.string()).optional(), - allVersionsWithChannels: z.array(VersionWithChannels).optional(), - /** @deprecated to be removed at some point, not used, left for compatibility with older versions */ - latest: descriptionType, - /** @deprecated to be removed at some point, not used, left for compatibility with older versions */ - latestManifestSha256: Sha256Schema, - latestByChannel: z - .record( - z.string(), - z - .object({ - description: descriptionType, - manifestSha256: Sha256Schema, - }) - .passthrough(), - ) - .default({}), - }) - .passthrough(); - return universalSchema - .transform((o) => { - if (o.allVersionsWithChannels) return o; - else - return { - ...o, - allVersionsWithChannels: o.allVersions!.map((v) => ({ version: v, channels: [] })), - }; - }) - .transform((o) => - o.latestByChannel[AnyChannel] - ? o - : { - ...o, - latestByChannel: { - ...o.latestByChannel, - [AnyChannel]: { description: o.latest!, manifestSha256: o.latestManifestSha256! }, - }, - }, - ) - .pipe(universalSchema.required({ allVersionsWithChannels: true })); +export type VersionWithChannels = { + version: string; + channels: string[]; +}; + +export type GlobalOverviewEntry = { + id: BlockPackIdNoVersion; + /** @deprecated left for compatibility with older versions */ + allVersions?: string[]; + allVersionsWithChannels: VersionWithChannels[]; + /** @deprecated left for compatibility with older versions */ + latest: D; + /** @deprecated left for compatibility with older versions */ + latestManifestSha256: string; + latestByChannel: Record; +}; + +export type GlobalOverview = { + schema: "v2"; + packages: GlobalOverviewEntry[]; +}; + +export type GlobalOverviewEntryReg = GlobalOverviewEntry; +export type GlobalOverviewReg = GlobalOverview; + +function migrateGlobalOverviewEntry(raw: unknown): GlobalOverviewEntry { + if (!raw || typeof raw !== "object") + throw new Error(`Invalid global overview entry: ${JSON.stringify(raw)}`); + const o = raw as Record & Partial>; + const allVersionsWithChannels = + o.allVersionsWithChannels ?? (o.allVersions ?? []).map((v) => ({ version: v, channels: [] })); + const latestByChannel = { ...(o.latestByChannel ?? {}) }; + if (!latestByChannel[AnyChannel] && o.latest !== undefined && o.latestManifestSha256) { + latestByChannel[AnyChannel] = { + description: o.latest as D, + manifestSha256: o.latestManifestSha256, + }; + } + return { + ...o, + id: o.id as BlockPackIdNoVersion, + allVersionsWithChannels, + latest: o.latest as D, + latestManifestSha256: (o.latestManifestSha256 ?? "") as string, + latestByChannel, + }; } -export const GlobalOverviewEntryReg = GlobalOverviewEntry(BlockPackDescriptionManifest); -export type GlobalOverviewEntryReg = z.infer; - -export function GlobalOverview( - descriptionType: Description, -) { - return z - .object({ - schema: z.literal("v2"), - packages: z.array(GlobalOverviewEntry(descriptionType)), - }) - .passthrough(); -} - -export const GlobalOverviewReg = GlobalOverview(BlockPackDescriptionManifest); -export type GlobalOverviewReg = z.infer; -export function BlockDescriptionToExplicitBinaryBytes(reader: RelativeContentReader) { - return CreateBlockPackDescriptionSchema( - BlockComponentsManifest, - BlockPackMeta( - ContentRelativeText.transform(relativeToExplicitString(reader)), - ContentRelativeBinary.transform(relativeToExplicitBytes(reader)), - ), - ); -} -export function GlobalOverviewToExplicitBinaryBytes(reader: RelativeContentReader) { - return GlobalOverview( - CreateBlockPackDescriptionSchema( - BlockComponentsManifest, - BlockPackMeta( - ContentRelativeText.transform(relativeToExplicitString(reader)), - ContentRelativeBinary.transform(relativeToExplicitBytes(reader)), - ), - ), - ); -} -export type GlobalOverviewExplicitBinaryBytes = z.infer< - ReturnType ->; - -export function GlobalOverviewToExplicitBinaryBase64(reader: RelativeContentReader) { - return GlobalOverview( - CreateBlockPackDescriptionSchema( - BlockComponentsManifest, - BlockPackMeta( - ContentRelativeText.transform(relativeToExplicitString(reader)), - ContentRelativeBinary.transform(relativeToExplicitBytes(reader)), - ), - ), +export function parseGlobalOverviewReg(raw: unknown): GlobalOverviewReg { + if (!raw || typeof raw !== "object" || (raw as { schema?: unknown }).schema !== "v2") + throw new Error(`Invalid global overview: schema != "v2"`); + const o = raw as { schema: "v2"; packages?: unknown[] }; + const packages = (o.packages ?? []).map((p) => + migrateGlobalOverviewEntry(p), ); + return { schema: "v2", packages }; } -export type GlobalOverviewExplicitBinaryBase64 = z.infer< - ReturnType ->; diff --git a/tools/block-tools/vite.config.mts b/tools/block-tools/vite.config.mts deleted file mode 100644 index 34afbb28a9..0000000000 --- a/tools/block-tools/vite.config.mts +++ /dev/null @@ -1,19 +0,0 @@ -import { defineConfig } from "vite"; -import { resolve } from "node:path"; -import nodeExternals from "rollup-plugin-node-externals"; -import dts from "vite-plugin-dts"; - -export default defineConfig({ - build: { - lib: { - entry: { - cli: resolve("src", "cmd", "index.ts"), - index: resolve("src", "lib.ts"), - }, - formats: ["es", "cjs"], - }, - sourcemap: true, - rolldownOptions: {}, - }, - plugins: [nodeExternals(), dts()], -}); diff --git a/tools/blocks-deps-updater/package.json b/tools/blocks-deps-updater/package.json index a56a3727ee..48cc85f536 100644 --- a/tools/blocks-deps-updater/package.json +++ b/tools/blocks-deps-updater/package.json @@ -11,13 +11,11 @@ "dist/" ], "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", - "require": "./dist/index.cjs", "import": "./dist/index.js" } }, diff --git a/tools/build-configs/package.json b/tools/build-configs/package.json index 6561326dcd..6cf7aa97c6 100644 --- a/tools/build-configs/package.json +++ b/tools/build-configs/package.json @@ -5,8 +5,7 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "import": "./dist/index.js" } }, "scripts": { diff --git a/tools/oclif-index/package.json b/tools/oclif-index/package.json index 13bb571545..65fc60eb9a 100644 --- a/tools/oclif-index/package.json +++ b/tools/oclif-index/package.json @@ -14,8 +14,7 @@ "./dist/" ], "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "main": "./dist/index.js", "scripts": { "build": "ts-builder build --target node", "watch": "ts-builder build --target node --watch", diff --git a/tools/package-builder/src/__test__/package.json b/tools/package-builder/src/__test__/package.json index af41a902c4..7c8de9aca4 100644 --- a/tools/package-builder/src/__test__/package.json +++ b/tools/package-builder/src/__test__/package.json @@ -1,6 +1,7 @@ { "name": "@platforma-open/docker-build-test", "version": "0.0.1", + "type": "module", "dependencies": { "@platforma-open/milaboratories.runenv-python-3": "catalog:" }, diff --git a/tools/pl-bootstrap/bin/dev.js b/tools/pl-bootstrap/bin/dev.js index 2d3f83bef2..8c75762795 100755 --- a/tools/pl-bootstrap/bin/dev.js +++ b/tools/pl-bootstrap/bin/dev.js @@ -1,4 +1,11 @@ #!/usr/bin/env node_modules/.bin/ts-node + +import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + // eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await (async () => { const oclif = await import("@oclif/core"); diff --git a/tools/pl-bootstrap/bin/run.js b/tools/pl-bootstrap/bin/run.js index 788bfa812b..c2dbc327d9 100755 --- a/tools/pl-bootstrap/bin/run.js +++ b/tools/pl-bootstrap/bin/run.js @@ -1,5 +1,11 @@ #!/usr/bin/env node +import { dirname } from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + // eslint-disable-next-line unicorn/prefer-top-level-await (async () => { const oclif = await import("@oclif/core"); diff --git a/tools/pl-bootstrap/package.json b/tools/pl-bootstrap/package.json index 9d523b9d5b..380efc6a67 100644 --- a/tools/pl-bootstrap/package.json +++ b/tools/pl-bootstrap/package.json @@ -12,9 +12,9 @@ "README.md", "bin/run.cmd", "bin/run.js", - "./assets/**", - "./postinstall.js" + "./assets/**" ], + "type": "module", "scripts": { "build": "oclif-index && node --run fmt && ts-builder build --target node", "watch": "ts-builder build --target node --watch", diff --git a/tools/pl-bootstrap/postinstsall.js b/tools/pl-bootstrap/postinstsall.js deleted file mode 100644 index 4c7ba8b617..0000000000 --- a/tools/pl-bootstrap/postinstsall.js +++ /dev/null @@ -1,5 +0,0 @@ -const pl = require("./dist/platforma"); -const util = require("./dist/util"); - -const logger = util.createLogger(); -pl.getBinary(logger); diff --git a/tools/ts-builder/src/configs/utils/createRolldownNodeConfig.ts b/tools/ts-builder/src/configs/utils/createRolldownNodeConfig.ts index 9d3450f16d..3d6ff36aef 100644 --- a/tools/ts-builder/src/configs/utils/createRolldownNodeConfig.ts +++ b/tools/ts-builder/src/configs/utils/createRolldownNodeConfig.ts @@ -10,7 +10,7 @@ export interface RolldownNodeConfigProps { export function createRolldownNodeConfig(props?: RolldownNodeConfigProps): RolldownOptions[] { const input = props?.entry ?? ["./src/index.ts"]; const output = props?.output ?? "dist"; - const formats = props?.formats ?? ["es", "cjs"]; + const formats = props?.formats ?? ["es"]; return formats.map((format) => createBuildEntry(input, output, format)); } diff --git a/tools/ts-configs/package.json b/tools/ts-configs/package.json index a01692a099..d1c9b316a7 100644 --- a/tools/ts-configs/package.json +++ b/tools/ts-configs/package.json @@ -1,6 +1,7 @@ { "name": "@milaboratories/ts-configs", "version": "1.2.3", + "type": "module", "exports": { "./package.json": "./package.json", "./browser": "./src/tsconfig.browser.json",