Skip to content

Commit

Permalink
Merge pull request #224 from eemeli/es-browsers
Browse files Browse the repository at this point in the history
Update build configs & minimum supported versions
  • Loading branch information
eemeli committed Jan 31, 2021
2 parents f58f351 + 42e84c8 commit 191270a
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 31 deletions.
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -24,8 +24,8 @@ npm test # just to be sure

## Repository Directory & File Structure

- **`browser/`** - Browser-optimised build of the library, which should work in IE 11 & later. Used automatically by e.g. Webpack & Rollup via the `"browser"` value in `package.json`. A corresponding minimal set of the library's required polyfills is available at `playground/src/polyfill.js`
- **`dist/`** - Node-optimised build of the library, which should work in Node.js 6.0.0 and later without polyfills.
- **`browser/`** - Browser-optimised ES build of the library, which should work in modern browsers. Used automatically by e.g. Webpack & Rollup via the `"browser"` value in `package.json`. A corresponding minimal set of the library's required polyfills is available at `playground/src/polyfill.js`
- **`dist/`** - Node-optimised build of the library, which should work in Node.js 10.0 and later without polyfills.
- **`docs/`** - Sources for the library's [documentation site](https://eemeli.org/yaml).
- **`docs-slate/`** - Compiler for the library's [documentation site](https://eemeli.org/yaml). Maintained as a git submodule to allow merges from its upstream source, [Slate](https://github.com/slatedocs/slate). See its [`README`](./docs-slate/README.md) for installation instructions. Note that the build target is the `gh-pages` branch of _this_ repo.
- **`playground/`** - Source files for a browser-based [playground](https://eemeli.org/yaml-playground/) using this library. Also contains the Selenium browser tests for the library. Maintained as a git submodule to allow for easier publication.
Expand All @@ -42,6 +42,8 @@ npm test # just to be sure

## Contributing Code

First of all, make sure that all the tests pass, and that you've added test cases covering your changes. Our set of test suites is rather extensive, and is a significant help in making sure no regressions are introduced. Note that the CI environment runs tests in e.g. Node.js 6.0 and IE 11, so using new language features may require extending the minimal set of [polyfills](./playground/src/polyfill.js)
First of all, make sure that all the tests pass, and that you've added test cases covering your changes.
Our set of test suites is rather extensive, and is a significant help in making sure no regressions are introduced.
Note that the CI environment runs tests in both Node.js and browsers, so using new language features may require extending the minimal set of [polyfills](./playground/src/polyfill.js)

If you're intending to contribute to the upstream repo, please make sure that your code style matches the Prettier and ESLint rules. The easiest way to do that is to configure your editor to do that for you, but `lint` and `prettier` npm scripts are also provided.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -2,7 +2,8 @@

`yaml` is a JavaScript parser and stringifier for [YAML](http://yaml.org/), a human friendly data serialization standard. It supports both parsing and stringifying data using all versions of YAML, along with all common data schemas. As a particularly distinguishing feature, `yaml` fully supports reading and writing comments and blank lines in YAML documents.

The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/). It has no external dependencies and runs on Node.js 6 and later, and in browsers from IE 11 upwards.
The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/).
It has no external dependencies and runs on Node.js as well as modern browsers.

For the purposes of versioning, any changes that break any of the endpoints or APIs documented here will be considered semver-major breaking changes. Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed).

Expand Down
3 changes: 2 additions & 1 deletion browser/index.js
@@ -1 +1,2 @@
module.exports = require('./dist')
export * as default from './dist'
export * from './dist'
File renamed without changes.
1 change: 0 additions & 1 deletion browser/types.js

This file was deleted.

1 change: 0 additions & 1 deletion browser/util.js

This file was deleted.

3 changes: 2 additions & 1 deletion docs/01_intro.md
Expand Up @@ -15,7 +15,8 @@ yarn add yaml@next
- Can accept any string as input without throwing, parsing as much YAML out of it as it can, and
- Supports parsing, modifying, and writing YAML comments.

The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/). It has no external dependencies and runs on Node.js 6 and later, and in browsers from IE 11 upwards.
The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/).
It has no external dependencies and runs on Node.js as well as modern browsers.

For the purposes of versioning, any changes that break any of the endpoints or APIs documented here will be considered semver-major breaking changes. Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed).

Expand Down
39 changes: 22 additions & 17 deletions package.json
Expand Up @@ -24,26 +24,31 @@
"main": "./index.js",
"browser": {
"./index.js": "./browser/index.js",
"./types.js": "./browser/types.js",
"./types.mjs": "./browser/types.js",
"./util.js": "./browser/util.js",
"./util.mjs": "./browser/util.js"
"./types.js": "./browser/dist/types.js",
"./types.mjs": "./browser/dist/types.js",
"./util.js": "./browser/dist/util.js",
"./util.mjs": "./browser/dist/util.js"
},
"exports": {
".": "./index.js",
".": {
"node": "./index.js",
"default": "./browser/index.js"
},
"./package.json": "./package.json",
"./types": [
{
"import": "./types.mjs"
"./types": {
"node": {
"import": "./types.mjs",
"require": "./types.js"
},
"./types.js"
],
"./util": [
{
"import": "./util.mjs"
"default": "./browser/dist/types.js"
},
"./util": {
"node": {
"import": "./util.mjs",
"require": "./util.js"
},
"./util.js"
]
"default": "./browser/dist/util.js"
}
},
"scripts": {
"build": "npm run build:node && npm run build:browser",
Expand All @@ -63,7 +68,7 @@
"preversion": "npm test && npm run build",
"prepublishOnly": "npm run clean && npm test && npm run build"
},
"browserslist": "> 0.5%, not dead",
"browserslist": "> 0.5%, not dead, not ie 11",
"prettier": {
"arrowParens": "avoid",
"semi": false,
Expand All @@ -89,6 +94,6 @@
"typescript": "^4.1.3"
},
"engines": {
"node": ">= 6"
"node": ">= 10"
}
}
2 changes: 1 addition & 1 deletion playground
5 changes: 3 additions & 2 deletions rollup.browser-config.js
Expand Up @@ -6,11 +6,12 @@ export default {
types: 'src/types.js',
util: 'src/util.js'
},
output: { dir: 'browser/dist', format: 'esm' },
output: { dir: 'browser/dist', format: 'esm', preserveModules: true },
plugins: [
babel({
babelHelpers: 'bundled',
presets: [['@babel/env', { modules: false }]]
})
]
],
treeshake: { moduleSideEffects: false, propertyReadSideEffects: false }
}
12 changes: 9 additions & 3 deletions rollup.node-config.js
Expand Up @@ -7,11 +7,17 @@ export default {
types: 'src/types.js',
util: 'src/util.js'
},
output: { dir: 'dist', format: 'cjs', esModule: false },
output: {
dir: 'dist',
format: 'cjs',
esModule: false,
preserveModules: true
},
plugins: [
babel({
babelHelpers: 'bundled',
presets: [['@babel/env', { modules: false, targets: { node: '6.5' } }]]
presets: [['@babel/env', { modules: false, targets: { node: '10.0' } }]]
})
]
],
treeshake: { moduleSideEffects: false, propertyReadSideEffects: false }
}

0 comments on commit 191270a

Please sign in to comment.