Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d1ae934
WIP
cspotcode Nov 8, 2021
bc1d314
Merge remote-tracking branch 'origin/main' into add-cjs-loader-resolve
cspotcode Nov 8, 2021
9a8f87e
restore .d.ts file
cspotcode Nov 8, 2021
4262420
Merge remote-tracking branch 'origin/main' into add-cjs-loader-resolve
cspotcode Apr 15, 2022
1885c1d
Merge remote-tracking branch 'origin/main' into add-cjs-loader-resolve
cspotcode Apr 20, 2022
7da5958
add notes and todos
cspotcode Apr 20, 2022
a61dba4
strip down node-internal-modules-cjs-loader to match main branch; wil…
cspotcode May 2, 2022
df272ab
committing all local stuff
cspotcode May 7, 2022
8782c3f
update
cspotcode May 8, 2022
f6e85a3
it kinda works!
cspotcode May 14, 2022
2140909
Merge remote-tracking branch 'origin/main' into add-cjs-loader-resolve-2
cspotcode May 14, 2022
f166f44
fix CI?
cspotcode May 14, 2022
a239ab4
fix?
cspotcode May 14, 2022
05cee32
fix?
cspotcode May 14, 2022
3c6defe
fix
cspotcode May 14, 2022
9c06277
bump up to node 18 cuz why not
cspotcode May 14, 2022
f4959d8
test matrix: replace node17 with node18
cspotcode May 14, 2022
104f045
fix node12 test failure
cspotcode May 14, 2022
1574a43
fix for prior hooks API
cspotcode May 14, 2022
1bd8f10
tweak
cspotcode May 14, 2022
9cb076c
fix
cspotcode May 14, 2022
9699cee
teach node environment resetter to re-sort require.extensions
cspotcode May 14, 2022
f9b50a7
fix
cspotcode May 14, 2022
d73f7d4
fix
cspotcode May 14, 2022
284d118
fix
cspotcode May 14, 2022
5cf6772
windows fix?
cspotcode May 14, 2022
59dd604
Addressing TODOs
cspotcode May 15, 2022
cc1f36d
sync another raw file with upstream
cspotcode May 15, 2022
c9d34b9
Improve reuse / DI within node ESM stuff
cspotcode May 15, 2022
e34adc0
cleanup node internalBinding stuff
cspotcode May 15, 2022
46096ab
Adding hint when ts-node is ignoring a file that you might want it to…
cspotcode May 15, 2022
f844b39
Add tests for self-imports and empty package.json manifests importing…
cspotcode May 15, 2022
e54686c
fix
cspotcode May 15, 2022
6f3fdd7
fix node12
cspotcode May 15, 2022
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
Prev Previous commit
Next Next commit
cleanup node internalBinding stuff
  • Loading branch information
cspotcode committed May 15, 2022
commit e34adc056cd77d0fa89a913720936a88bafc2ba7
39 changes: 0 additions & 39 deletions dist-raw/node-internal-fs.js

This file was deleted.

3 changes: 1 addition & 2 deletions dist-raw/node-internal-modules-cjs-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { pathToFileURL, fileURLToPath } = require('url');
const fs = require('fs');
const path = require('path');
const { sep } = path;
const { internalModuleStat } = require('./node-internal-fs');
const { internalModuleStat } = require('./node-internalBinding-fs');
const packageJsonReader = require('./node-internal-modules-package_json_reader');
const {
cjsConditions,
Expand Down Expand Up @@ -129,7 +129,6 @@ function readPackageScope(checkPath) {
* }} opts
*/
function createCjsLoader(opts) {
// TODO don't need this if we get it from Object.keys(module.extensions) always?
const {nodeEsmResolver, compiledExtensions, preferTsExts} = opts;
const {
encodedSepRegEx,
Expand Down
2 changes: 1 addition & 1 deletion dist-raw/node-internal-modules-package_json_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

const { SafeMap } = require('./node-primordials');
const { internalModuleReadJSON } = require('./node-internal-fs');
const { internalModuleReadJSON } = require('./node-internalBinding-fs');
const { pathToFileURL } = require('url');
const { toNamespacedPath } = require('path');
// const { getOptionValue } = require('./node-options');
Expand Down
5 changes: 0 additions & 5 deletions dist-raw/node-internalBinding-fs.d.ts

This file was deleted.

42 changes: 40 additions & 2 deletions dist-raw/node-internalBinding-fs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
// TODO unify this with node-internal-fs?
const fs = require('fs');

exports.internalModuleStat = function(path) {
// In node's core, this is implemented in C
// https://github.com/nodejs/node/blob/v15.3.0/src/node_file.cc#L891-L985
/**
* @param {string} path
* @returns {[] | [string, boolean]}
*/
function internalModuleReadJSON(path) {
let string
try {
string = fs.readFileSync(path, 'utf8')
} catch (e) {
if (e.code === 'ENOENT') return []
throw e
}
// Node's implementation checks for the presence of relevant keys: main, name, type, exports, imports
// Node does this for performance to skip unnecessary parsing.
// This would slow us down and, based on our usage, we can skip it.
const containsKeys = true
return [string, containsKeys]
}

// In node's core, this is implemented in C
// https://github.com/nodejs/node/blob/63e7dc1e5c71b70c80ed9eda230991edb00811e2/src/node_file.cc#L987-L1005
/**
* @param {string} path
* @returns {number} 0 = file, 1 = dir, negative = error
*/
function internalModuleStat(path) {
try {
const stat = fs.statSync(path);
if(stat.isFile()) return 0;
if(stat.isDirectory()) return 1;
} catch(e) {
return -e.errno || -1;
}
}

module.exports = {
internalModuleReadJSON,
internalModuleStat
};