Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist-raw/node-package-json-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { SafeMap } = require('./node-primordials');
const { internalModuleReadJSON } = require('./node-internal-fs');
const { pathToFileURL } = require('url');
const { toNamespacedPath } = require('path');
// const { getOptionValue } = require('./node-options');

const cache = new SafeMap();

Expand All @@ -23,7 +24,6 @@ function read(jsonPath) {
toNamespacedPath(jsonPath)
);
const result = { string, containsKeys };
const { getOptionValue } = require('./node-options');
if (string !== undefined) {
if (manifest === undefined) {
// manifest = getOptionValue('--experimental-policy') ?
Expand Down
39 changes: 39 additions & 0 deletions src/test/regression.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Misc regression tests go here if they do not have a better home

import * as exp from 'expect';
import { join } from 'path';
import { createExec, createExecTester } from './exec-helpers';
import {
CMD_TS_NODE_WITHOUT_PROJECT_FLAG,
contextTsNodeUnderTest,
TEST_DIR,
} from './helpers';
import { test as _test } from './testlib';

const test = _test.context(contextTsNodeUnderTest);
const exec = createExecTester({
exec: createExec({
cwd: TEST_DIR,
}),
});

test('#1488 regression test', async () => {
// Scenario that caused the bug:
// `allowJs` turned on
// `skipIgnore` turned on so that ts-node tries to compile itself (not ideal but theoretically we should be ok with this)
// Attempt to `require()` a `.js` file
// `assertScriptCanLoadAsCJS` is triggered within `require()`
// `./package.json` needs to be fetched into cache via `assertScriptCanLoadAsCJS` which caused a recursive `require()` call
// Circular dependency warning is emitted by node

const { stdout, stderr } = await exec({
exec: createExec({
cwd: join(TEST_DIR, '1488'),
}),
cmd: `${CMD_TS_NODE_WITHOUT_PROJECT_FLAG} ./index.js`,
});

// Assert that we do *not* get `Warning: Accessing non-existent property 'getOptionValue' of module exports inside circular dependency`
exp(stdout).toBe('foo\n'); // prove that it ran
exp(stderr).toBe(''); // prove that no warnings
});
1 change: 1 addition & 0 deletions tests/1488/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('foo');
1 change: 1 addition & 0 deletions tests/1488/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
8 changes: 8 additions & 0 deletions tests/1488/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"allowJs": true
},
"ts-node": {
"skipIgnore": true
}
}