module: error for CJS .js load within type: module

PR-URL: https://github.com/nodejs/node/pull/29492
Reviewed-By: Jan Krems <jan.krems@gmail.com>
This commit is contained in:
Guy Bedford authored and Jan Krems committed 2019-09-19 15:24:50 -07:00
1 parent ac41959922
commit 4396bebfe1
5 files changed
+87 -34

No files matched your search

+28
View File
@@ -212,6 +212,10 @@ test({
shouldFail: false,
entry: parentFilepath,
resources: {
[packageURL]: {
body: packageBody,
match: true,
},
[parentURL]: {
body: parentBody,
match: true,
@@ -227,6 +231,10 @@ test({
preload: [depFilepath],
entry: parentFilepath,
resources: {
[packageURL]: {
body: packageBody,
match: true,
},
[parentURL]: {
body: parentBody,
match: true,
@@ -279,6 +287,10 @@ test({
shouldFail: false,
entry: depFilepath,
resources: {
[packageURL]: {
body: packageBody,
match: true,
},
[depURL]: {
body: depBody,
match: true,
@@ -289,6 +301,10 @@ test({
shouldFail: false,
entry: depFilepath,
resources: {
[packageURL]: {
body: packageBody,
match: true,
},
[policyToDepRelativeURLString]: {
body: depBody,
match: true,
@@ -309,6 +325,10 @@ test({
shouldFail: false,
entry: depFilepath,
resources: {
[packageURL]: {
body: packageBody,
match: true,
},
[policyToDepRelativeURLString]: {
body: depBody,
match: true,
@@ -351,6 +371,10 @@ test({
shouldFail: false,
entry: workerSpawningFilepath,
resources: {
[packageURL]: {
body: packageBody,
match: true,
},
[workerSpawningURL]: {
body: workerSpawningBody,
match: true,
@@ -370,6 +394,10 @@ test({
entry: workerSpawningFilepath,
preload: [parentFilepath],
resources: {
[packageURL]: {
body: packageBody,
match: true,
},
[workerSpawningURL]: {
body: workerSpawningBody,
match: true,
@@ -36,8 +36,16 @@ if (!tmpdirURL.pathname.endsWith('/')) {
tmpdirURL.pathname += '/';
}
const packageFilepath = path.join(tmpdir.path, 'package.json');
const packageURL = pathToFileURL(packageFilepath);
const packageBody = '{"main": "dep.js"}';
function test({ shouldFail, integrity }) {
const resources = {
[packageURL]: {
body: packageBody,
integrity: `sha256-${hash('sha256', packageBody)}`
},
[depURL]: {
body: depBody,
integrity