chore(defined): remove build step

It also helps with compatibility with Native ESM for default exports.
This commit is contained in:
Julien Fontanet 2021-05-19 12:06:07 +02:00
parent 68bb2fa7f0
commit a64af4da7c
5 changed files with 8 additions and 19 deletions

View File

@ -1 +0,0 @@
module.exports = require('../../@xen-orchestra/babel-config')(require('./package.json'))

View File

@ -1 +0,0 @@
../../scripts/babel-eslintrc.js

View File

@ -11,7 +11,7 @@
// process.env.http_proxy // process.env.http_proxy
// ]) // ])
// ``` // ```
export default function defined() { function defined() {
let args = arguments let args = arguments
let n = args.length let n = args.length
if (n === 1) { if (n === 1) {
@ -29,6 +29,7 @@ export default function defined() {
} }
} }
} }
module.exports = exports = defined
// Usage: // Usage:
// //
@ -39,7 +40,7 @@ export default function defined() {
// const getFriendName = _ => _.friends[0].name // const getFriendName = _ => _.friends[0].name
// const friendName = get(getFriendName, props.user) // const friendName = get(getFriendName, props.user)
// ``` // ```
export const get = (accessor, arg) => { function get(accessor, arg) {
try { try {
return accessor(arg) return accessor(arg)
} catch (error) { } catch (error) {
@ -49,6 +50,7 @@ export const get = (accessor, arg) => {
} }
} }
} }
exports.get = get
// Usage: // Usage:
// //
@ -58,4 +60,6 @@ export const get = (accessor, arg) => {
// _ => new ProxyAgent(_) // _ => new ProxyAgent(_)
// ) // )
// ``` // ```
export const ifDef = (value, thenFn) => (value !== undefined ? thenFn(value) : value) exports.ifDef = function ifDef(value, thenFn) {
return value !== undefined ? thenFn(value) : value
}

View File

@ -16,27 +16,13 @@
"url": "https://vates.fr" "url": "https://vates.fr"
}, },
"preferGlobal": false, "preferGlobal": false,
"main": "dist/",
"browserslist": [ "browserslist": [
">2%" ">2%"
], ],
"engines": { "engines": {
"node": ">=6" "node": ">=6"
}, },
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"cross-env": "^7.0.2",
"rimraf": "^3.0.0"
},
"scripts": { "scripts": {
"build": "cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
"clean": "rimraf dist/",
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"prebuild": "yarn run clean",
"predev": "yarn run prebuild",
"prepublishOnly": "yarn run build",
"postversion": "npm publish" "postversion": "npm publish"
} }
} }

View File

@ -33,6 +33,7 @@
> >
> In case of conflict, the highest (lowest in previous list) `$version` wins. > In case of conflict, the highest (lowest in previous list) `$version` wins.
- @xen-orchestra/defined patch
- xo-collection minor - xo-collection minor
- @xen-orchestra/log patch - @xen-orchestra/log patch
- xen-api minor - xen-api minor