-
Notifications
You must be signed in to change notification settings - Fork 150
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When bundling yaml for the browser using rollup, I get a circular dependency error. This seems to be a quirk (maybe even a bug?) of the way rollup builds for the browser. A small tweak seems to solve the problem.
Change this,
import * as YAML from './dist/index.js'to this,
import * as YAML from '../browser/dist/index.js'To Reproduce
Here's a minimal reproduction.
package.json
{
"scripts": {
"build": "rollup -c"
},
"dependencies": {
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"rollup": "^2.52.4",
"yaml": "^2.0.0-6"
}
}rollup.config.js
const { nodeResolve } = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");
module.exports = {
input: "index.js",
output: {
format: "iife",
file: "dist.js",
name: "Test",
exports: "auto"
},
plugins: [
nodeResolve({
browser: true
}),
commonjs(),
]
};index.js
const YAML = require("yaml");
const data = YAML.parse(`foo: bar`);
console.log(data);Run rollup with npm run build. You should see the circular dependency error. Make the change suggested above (or a better one if it exists) and the error goes away and you can run the bundled app with node dist.js.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working