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

Converge esm imports #776

Merged
merged 5 commits into from
Nov 3, 2020
Merged

Converge esm imports #776

merged 5 commits into from
Nov 3, 2020

Conversation

semmel
Copy link
Member

@semmel semmel commented Oct 26, 2020

Fixes #774

I left out the Node.js import test because it would require creating a new npm project and npm installing baconjs.

Here is the code anyway:

// file: testBareImport.mjs
import * as Bacon from 'baconjs';
import pkg from "chai";
const { assert } = pkg;

describe("Bare ES6 import in Node.js", function() {
	it("passes smoke test", () =>
		Bacon.sequentially(10, [1, 2, 3])
		.map(x => x * x)
		.reduce(0, (acc, y) => acc +y)
		.toPromise()
		.then(sum => assert.equal(sum, 14))
	);
	it ("imports the ES6 classes", () => {
		// ES6 class constructors require 'new'
		// So while with ES5 constructor functions calls without 'new'
		// do not throw, calls to ES6 constructors throw TypeError
		assert.throws(() => {Bacon.Error("woo");}, TypeError);
	});
});

Execute with $mocha testBareImport.mjs.

@raimohanska raimohanska merged commit 001aac9 into master Nov 3, 2020
@raimohanska
Copy link
Contributor

Included in 3.0.17

@semmel semmel deleted the converge-esm-imports branch November 20, 2020 19:28
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.

Converge ES6 module imports for browser and Node.js
2 participants