Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/yaml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## Requirements

This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.

## Install

Expand Down
37 changes: 23 additions & 14 deletions packages/yaml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
"author": "rollup",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/yaml/#readme",
"bugs": "https://github.com/rollup/plugins/issues",
"main": "dist/index.js",
"module": "dist/index.es.js",
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"exports": {
"types": "./types/index.d.ts",
"import": "./dist/es/index.js",
"default": "./dist/cjs/index.js"
},
"engines": {
"node": ">=10.0.0"
"node": ">=14.0.0"
},
"scripts": {
"build": "rollup -c",
Expand All @@ -33,6 +38,7 @@
},
"files": [
"dist",
"!dist/**/*.map",
"types",
"README.md",
"LICENSE"
Expand All @@ -43,24 +49,27 @@
"yaml"
],
"peerDependencies": {
"rollup": "^1.20.0 || ^2.0.0"
"rollup": "^1.20.0||^2.0.0||^3.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
},
"dependencies": {
"@rollup/pluginutils": "^3.1.0",
"js-yaml": "^3.14.0",
"tosource": "^1.0.0"
"@rollup/pluginutils": "^4.2.1",
"js-yaml": "^4.1.0",
"tosource": "^2.0.0-alpha.3"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^8.4.0",
"del-cli": "^3.0.1",
"rollup": "^2.67.3",
"source-map-support": "^0.5.19"
"@rollup/plugin-node-resolve": "^14.1.0",
"del-cli": "^5.0.0",
"rollup": "^3.0.0-7",
"source-map-support": "^0.5.21"
},
"types": "./types/index.d.ts",
"ava": {
"babel": {
"compileEnhancements": false
},
"workerThreads": false,
"files": [
"!**/fixtures/**",
"!**/helpers/**",
Expand Down
10 changes: 0 additions & 10 deletions packages/yaml/rollup.config.js

This file was deleted.

11 changes: 11 additions & 0 deletions packages/yaml/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { readFileSync } from 'fs';

import { createConfig } from '../../shared/rollup.config.mjs';

export default {
...createConfig({
pkg: JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
}),
input: 'src/index.js',
plugins: []
};
7 changes: 3 additions & 4 deletions packages/yaml/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ import { createFilter, makeLegalIdentifier } from '@rollup/pluginutils';

const defaults = {
documentMode: 'single',
safe: true,
transform: null
};
const ext = /\.ya?ml$/;

export default function yaml(opts = {}) {
const options = Object.assign({}, defaults, opts);
const { documentMode, safe } = options;
const { documentMode } = options;
const filter = createFilter(options.include, options.exclude);
let loadMethod = null;

if (documentMode === 'single') {
loadMethod = safe ? YAML.load : YAML.safeLoad;
loadMethod = YAML.load;
} else if (documentMode === 'multi') {
loadMethod = safe ? YAML.loadAll : YAML.safeLoadAll;
loadMethod = YAML.loadAll;
} else {
this.error(
`plugin-yaml → documentMode: '${documentMode}' is not a valid value. Please choose 'single' or 'multi'`
Expand Down
6 changes: 3 additions & 3 deletions packages/yaml/test/fixtures/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
},
{
"yaml": "02472256",
"result": 685230
"result": 2472256
},
{
"yaml": "0x_0A_74_AE",
Expand All @@ -123,7 +123,7 @@
},
{
"yaml": "190:20:30",
"result": 685230
"result": "190:20:30"
}
],

Expand Down Expand Up @@ -166,7 +166,7 @@
},
{
"yaml": "190:20:30.15",
"result": 685230.15
"result": "190:20:30.15"
}
],

Expand Down
16 changes: 0 additions & 16 deletions packages/yaml/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,6 @@ test('documentMode: multi', async (t) => {
return testBundle(t, bundle);
});

test('documentMode: multi, safe', async (t) => {
const bundle = await rollup.rollup({
input: 'fixtures/multi/main.js',
plugins: [yaml({ documentMode: 'multi', safe: false })]
});
return testBundle(t, bundle);
});

test('converts yaml, safe', async (t) => {
const bundle = await rollup.rollup({
input: 'fixtures/basic/main.js',
plugins: [yaml({ safe: false })]
});
return testBundle(t, bundle);
});

test('bad documentMode', async (t) => {
const exec = () =>
rollup.rollup({
Expand Down
1 change: 0 additions & 1 deletion packages/yaml/test/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const config: RollupOptions = {
yaml({
include: 'node_modules/**',
exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
safe: true,
documentMode: 'single',
transform(data, path) {
if (typeof data === 'string' && data.includes('<filePath>')) {
Expand Down
8 changes: 0 additions & 8 deletions packages/yaml/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ interface RollupYamlOptions {
* By default no files are ignored.
*/
exclude?: FilterPattern;
/**
* - If `true`, specifies that the data in the target YAML file(s) contain trusted data and
* should be loaded normally.
* - If `false`, data is assumed to be untrusted and will be loaded using
* [safety methods](https://github.com/nodeca/js-yaml#safeload-string---options-).
* @default true
*/
safe?: boolean;
/**
* A function which can optionally mutate parsed YAML.
* The function should return the mutated `object`, or `undefined` which will make no changes to
Expand Down
Loading