Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
test: add additional fixtures and tests for irp
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesBorins committed Mar 4, 2019
1 parent 0c15920 commit 6c03eed
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/es-module/test-esm-package-scope.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */

import '../common/index.mjs';
import assert from 'assert';

import legacyLoader from '../fixtures/esm-package-scope/legacy-loader/index.mjs';
import newLoader from '../fixtures/esm-package-scope/new-loader/index.js';

assert.strictEqual(legacyLoader, 'legacy-loader');
assert.strictEqual(newLoader, 'new-loader');
1 change: 1 addition & 0 deletions test/fixtures/esm-package-scope/legacy-loader/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'a';
1 change: 1 addition & 0 deletions test/fixtures/esm-package-scope/legacy-loader/b.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const b = 'b';
5 changes: 5 additions & 0 deletions test/fixtures/esm-package-scope/legacy-loader/c.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
one: 1,
two: 2,
three: 3
};
21 changes: 21 additions & 0 deletions test/fixtures/esm-package-scope/legacy-loader/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// js file that is common.js
import a from './a.js';
// ESM with named export
import {b} from './b.mjs';
// import 'c.cjs';
import cjs from './c.cjs';
// proves cross boundary fun bits
import jsAsEsm from '../new-loader/a.js';

// named export from core
import {strictEqual, deepStrictEqual} from 'assert';

strictEqual(a, jsAsEsm);
strictEqual(b, 'b');
deepStrictEqual(cjs, {
one: 1,
two: 2,
three: 3
});

export default 'legacy-loader';
13 changes: 13 additions & 0 deletions test/fixtures/esm-package-scope/legacy-loader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "legacy-loader",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Myles Borins <mylesborins@google.com>",
"license": "Apache-2.0",
"type": "commonjs"
}
1 change: 1 addition & 0 deletions test/fixtures/esm-package-scope/new-loader/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'a'
1 change: 1 addition & 0 deletions test/fixtures/esm-package-scope/new-loader/b.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const b = 'b';
5 changes: 5 additions & 0 deletions test/fixtures/esm-package-scope/new-loader/c.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
one: 1,
two: 2,
three: 3
};
21 changes: 21 additions & 0 deletions test/fixtures/esm-package-scope/new-loader/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ESM with only default
import a from './a.js';
// ESM with named export
import {b} from './b.mjs';
// import 'c.cjs';
import cjs from './c.cjs';
// import across boundaries
import jsAsCjs from '../legacy-loader/a.js'

// named export from core
import {strictEqual, deepStrictEqual} from 'assert';

strictEqual(a, jsAsCjs);
strictEqual(b, 'b');
deepStrictEqual(cjs, {
one: 1,
two: 2,
three: 3
});

export default 'new-loader';
13 changes: 13 additions & 0 deletions test/fixtures/esm-package-scope/new-loader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "new-loader",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Myles Borins <mylesborins@google.com>",
"license": "Apache-2.0",
"type": "module"
}

0 comments on commit 6c03eed

Please sign in to comment.