diff --git a/publicodes/esm/index.js b/publicodes/esm/index.js new file mode 100644 index 000000000..908e66f24 --- /dev/null +++ b/publicodes/esm/index.js @@ -0,0 +1,12 @@ +// ESM wrapper arrond publicodes CJS Module +// For a deep explanation see: +// https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1 + +import publicodes from '../dist/index.js'; +export default publicodes.default +export const reduceAST = publicodes.reduceAST; +export const transformAST = publicodes.transformAST; +export const formatValue = publicodes.formatValue; +export const utils = publicodes.utils; +export const translateRules = publicodes.translateRules; +export const evaluateRule = publicodes.evaluateRule; \ No newline at end of file diff --git a/publicodes/esm/package.json b/publicodes/esm/package.json new file mode 100644 index 000000000..dd1b5c374 --- /dev/null +++ b/publicodes/esm/package.json @@ -0,0 +1,6 @@ +{ + "type": "module", + "engines": { + "node": ">=15.0.0" + } +} \ No newline at end of file diff --git a/publicodes/package.json b/publicodes/package.json index 7affa6775..8b4149f8e 100644 --- a/publicodes/package.json +++ b/publicodes/package.json @@ -4,6 +4,10 @@ "description": "A declarative language for encoding public algorithm", "main": "dist/index.js", "types": "dist/types/index.d.ts", + "exports": { + "require": "./dist/index.js", + "import": "./esm/index.js" + }, "repository": { "type": "git", "url": "https://github.com/betagouv/mon-entreprise.git", @@ -15,7 +19,8 @@ "files": [ "dist/index.js", "dist/types", - "dist/images" + "dist/images", + "esm" ], "private": false, "devDependencies": {