Skip to content
Permalink
Browse files
support @std/esm (#1618)
* support @std/esm

* fix path test for windows

* fix linter error

* Stricter regex. Use shorthand .esmrc file in fixture.

* update package-lock.json
  • Loading branch information
jamestalmage committed Jan 8, 2018
1 parent 29e5dfd commit 72c53bee0766a7e45595919f97f114073c93bff7
Showing 7 changed files with 35 additions and 1 deletion.
@@ -27,7 +27,13 @@ globals.options = opts;

const serializeError = require('./serialize-error');

(opts.require || []).forEach(x => require(x));
(opts.require || []).forEach(x => {
if (/[/\\]@std[/\\]esm[/\\]index\.js$/.test(x)) {
require = require(x)(module); // eslint-disable-line no-global-assign
} else {
require(x);
}
});

adapter.installSourceMapSupport();
adapter.installPrecompilerHook();

Some generated files are not rendered by default. Learn more.

@@ -146,6 +146,7 @@
"update-notifier": "^2.3.0"
},
"devDependencies": {
"@std/esm": "^0.19.1",
"cli-table2": "^0.2.0",
"codecov": "^3.0.0",
"del": "^3.0.0",
@@ -0,0 +1,3 @@
{
"esm": "cjs"
}
@@ -0,0 +1 @@
export default 'foo';
@@ -0,0 +1,6 @@
import test from '../../../';
import m from '.';

test('works', t => {
t.is(m, 'foo');
});
@@ -135,6 +135,17 @@ test('babelrc is ignored', t => {
});
});

test('@std/esm support', t => {
return fork(fixture('std-esm/test.js'), {
require: [require.resolve('@std/esm')]
})
.run({})
.then(info => {
t.is(info.stats.passCount, 1);
t.end();
});
});

// TODO: Skipped until we can do this properly in #1455
test('color support is initialized correctly', t => {
t.plan(1);

2 comments on commit 72c53be

@BenSower
Copy link

@BenSower BenSower commented on 72c53be Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks nice, is there any documentation on this, yet? From what I see, this just allows ava to use std-esm out of the box instead of having to add it to the dependencies manually, right?

@novemberborn
Copy link
Member

@novemberborn novemberborn commented on 72c53be Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenSower you still need to add it to your package's dependencies.

Regarding documentation, there's a stalled PR (#1593, see #1590 for the issue). Perhaps you'd want to pick that up?

Please sign in to comment.