Ajoute la possibilité d'importer publicodes en ESModule natif
Pour cela, la solution la plus simple est de faire un wrapper autour de l'api exposée. Il ne faudra pas oublier de le mettre à jour. [A lire pour en savoir plus](https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1) fix #1239pull/1309/head
parent
6390307be6
commit
0d50e03777
|
@ -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;
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=15.0.0"
|
||||
}
|
||||
}
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in New Issue