Skip to content

Commit

Permalink
Add ES module exports + set type in package.json (Fixes #138)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Mar 7, 2020
1 parent 2b4b8d4 commit 7acfb9a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"dist/",
"types/",
"*.js",
"*.mjs",
"!.*.js"
],
"type": "commonjs",
"main": "./index.js",
"browser": {
"./index.js": "./browser/index.js",
Expand All @@ -35,6 +37,18 @@
"./types/timestamp.js": "./browser/types/timestamp.js",
"./util.js": "./browser/util.js"
},
"exports": {
".": "./index.js",
"./parse-cst": "./parse-cst.js",
"./types": {
"require": "./types.js",
"import": "./types.mjs"
},
"./util": {
"require": "./util.js",
"import": "./util.mjs"
}
},
"scripts": {
"browser:build": "BABEL_ENV=browser babel src/ --out-dir browser/dist/",
"browser:copy": "cpy '*.js' '!*.config.js' types/ browser/ --parents",
Expand Down
20 changes: 20 additions & 0 deletions types.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import opt from './dist/tags/options.js'
export const binaryOptions = opt.binaryOptions
export const boolOptions = opt.boolOptions
export const nullOptions = opt.nullOptions
export const strOptions = opt.strOptions

import schema from './dist/schema/index.js'
export const Schema = schema.default

import map from './dist/schema/Map.js'
export const YAMLMap = map.default

import seq from './dist/schema/Seq.js'
export const YAMLSeq = seq.default

import pair from './dist/schema/Pair.js'
export const Pair = pair.default

import scalar from './dist/schema/Scalar.js'
export const Scalar = scalar.default
24 changes: 24 additions & 0 deletions util.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import map from './dist/schema/Map.js'
export const findPair = map.findPair

import parseMapPkg from './dist/schema/parseMap.js'
export const parseMap = parseMapPkg.default

import parseSeqPkg from './dist/schema/parseSeq.js'
export const parseSeq = parseSeqPkg.default

import str from './dist/stringify.js'
export const stringifyNumber = str.stringifyNumber
export const stringifyString = str.stringifyString

import toJsonPkg from './dist/toJSON.js'
export const toJSON = toJsonPkg.default

import constants from './dist/constants.js'
export const Type = constants.Type

import err from './dist/errors.js'
export const YAMLReferenceError = err.YAMLReferenceError
export const YAMLSemanticError = err.YAMLSemanticError
export const YAMLSyntaxError = err.YAMLSyntaxError
export const YAMLWarning = err.YAMLWarning

0 comments on commit 7acfb9a

Please sign in to comment.