Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 'yaml/types' into 'yaml' & fiddle with 'yaml/util' #234

Merged
merged 6 commits into from Mar 6, 2021
Merged

Conversation

eemeli
Copy link
Owner

@eemeli eemeli commented Feb 27, 2021

Especially with the port to TypeScript, it makes less sense now to expose 'yaml/types' separately from 'yaml'. So let's not.

This is how you'll need to update your imports, if using:

-import { Alias, Merge, Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml/types'
+import { Alias, Merge, Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml'

-import { binaryOptions, boolOptions, intOptions, nullOptions, strOptions } from 'yaml/types'
+import { scalarOptions } from 'yaml'
+const boolOptions = scalarOptions.bool

A couple of the 'yaml/util' exports also make more sense on 'yaml':

-import { Type, YAMLError, YAMLParseError, YAMLWarning } from 'yaml/util'
+import { Type, YAMLError, YAMLParseError, YAMLWarning } from 'yaml'

While we're at this, let's also add a couple of things to 'yaml/util' that weren't exposed before:

import { debug, warn, foldFlowLines } from 'yaml/util'

And finally, let's clear up things from the repo root that aren't needed anymore, or that we can easily hide in a config/ directory. Leaving the Prettier & ESLint config there at least for now, because otherwise editors wouldn't find them automatically.

If you're using ES modules in Node.js < 14.10, this may change how you need to import 'yaml/util', as the automatic named exports weren't generated for CommonJS imports until then. My suspicion is that this would affect a vanishingly small number of users, but please do let me know if it's a problem:

// Both forms are fine in Node.js 14.10 & later, and for all bundlers
-import { stringifyNumber } from 'yaml/util'
+import Util from 'yaml/util'
+const { stringifyNumber } = Util

BREAKING CHANGE: Imports previously available from 'yaml/types' are now
provided from 'yaml':

-import { Alias, Merge, Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml/types'
+import { Alias, Merge, Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml'

-import { binaryOptions, boolOptions, intOptions, nullOptions, strOptions } from 'yaml/types'
+import { scalarOptions } from 'yaml'
+const boolOptions = scalarOptions.bool
BREAKING CHANGE: Users will need to update their imports:

-import { Type, YAMLError, YAMLParseError, YAMLWarning } from 'yaml/util'
+import { Type, YAMLError, YAMLParseError, YAMLWarning } from 'yaml'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant