@tapjs/processinfo 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mjs/hooks.d.mts.map +1 -1
- package/dist/mjs/hooks.mjs +4 -4
- package/dist/mjs/hooks.mjs.map +1 -1
- package/package.json +1 -1
package/dist/mjs/hooks.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.mts","sourceRoot":"","sources":["../../src/hooks.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hooks.d.mts","sourceRoot":"","sources":["../../src/hooks.mts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AActD,eAAO,MAAM,aAAa,YAAa;IAAE,IAAI,CAAC,EAAE,WAAW,CAAA;CAAE,WAwB5D,CAAA;AAED,eAAO,MAAM,UAAU;UAAsB,WAAW;UAEvD,CAAA;AAsBD,eAAO,MAAM,IAAI,QACV,MAAM,WACF,GAAG,YACF,QAAQ,iBAyBnB,CAAA;AAGD,eAAO,MAAM,KAAK,YAGjB,CAAA"}
|
package/dist/mjs/hooks.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// hooks used by loader-legacy.mjs and loader.mjs
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
2
|
import { parse } from 'node:path';
|
|
4
3
|
import { fileURLToPath } from 'node:url';
|
|
5
4
|
import { getExclude } from './get-exclude.js';
|
|
@@ -46,9 +45,6 @@ const record = async (url, content) => {
|
|
|
46
45
|
if (fakeMains.includes(filename)) {
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
|
-
// try to get the actual contents of the file on disk, since it has
|
|
50
|
-
// likely been transpiled by the time we get at it.
|
|
51
|
-
content = await readFile(filename, 'utf8').catch(() => content);
|
|
52
48
|
if (PORT) {
|
|
53
49
|
PORT.postMessage({ filename, content });
|
|
54
50
|
}
|
|
@@ -66,14 +62,18 @@ export const load = async (url, context, nextLoad) => {
|
|
|
66
62
|
// instead of just naming their extensioned file and letting npm
|
|
67
63
|
// symlink it for them. Don't blow up when this happens, just tell
|
|
68
64
|
// node that it's commonjs.
|
|
65
|
+
// TODO: should we just let this fail? It fails *without* the loader,
|
|
66
|
+
// after all.
|
|
69
67
|
if (!ext) {
|
|
70
68
|
await record(url);
|
|
71
69
|
return {
|
|
70
|
+
...context,
|
|
72
71
|
format: 'commonjs',
|
|
73
72
|
shortCircuit: true,
|
|
74
73
|
};
|
|
75
74
|
}
|
|
76
75
|
}
|
|
76
|
+
// we actually need the transpiled
|
|
77
77
|
const ret = await nextLoad(url, context);
|
|
78
78
|
await record(url, ret.source);
|
|
79
79
|
return ret;
|
package/dist/mjs/hooks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.mjs","sourceRoot":"","sources":["../../src/hooks.mts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"hooks.mjs","sourceRoot":"","sources":["../../src/hooks.mts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EACL,cAAc,IAAI,eAAe,EACjC,KAAK,IAAI,gBAAgB,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,IAAI,cAAc,GAAG,eAAe,CAAA;AAEpC,IAAI,IAAI,GAA4B,SAAS,CAAA;AAE7C,MAAM,CAAC,MAAM,aAAa,GA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C,SAAS,CAAC,EAAE;QAC7B,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;QACnC,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC/B,+DAA+D;QAC/D,gEAAgE;QAChE,kEAAkE;QAClE,2BAA2B;QAC3B,qEAAqE;QACrE,aAAa;QACb,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,MAAM,CAAC,GAAG,CAAC,CAAA;YACjB,OAAO;gBACL,GAAG,OAAO;gBACV,MAAM,EAAE,UAAU;gBAClB,YAAY,EAAE,IAAI;aACnB,CAAA;SACF;KACF;IAED,kCAAkC;IAClC,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACxC,MAAM,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,EAAE;IACxB,IAAI,GAAG,SAAS,CAAA;IAChB,cAAc,GAAG,gBAAgB,EAAE,CAAC,cAAc,CAAA;AACpD,CAAC,CAAA","sourcesContent":["// hooks used by loader-legacy.mjs and loader.mjs\n\nimport { parse } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { MessagePort } from 'node:worker_threads'\nimport { getExclude } from './get-exclude.js'\nimport { getImportMetaURL } from './get-import-meta-url.js'\nimport { fakeMains } from './get-main.js'\nimport {\n getProcessInfo as _getProcessInfo,\n reset as processInfoReset,\n} from './get-process-info.js'\nimport { saveLineLengths } from './line-lengths.js'\n\nlet getProcessInfo = _getProcessInfo\n\nlet PORT: undefined | MessagePort = undefined\n\nexport const globalPreload = (context: { port?: MessagePort }) => {\n // this will be something like path/to/dist/mjs/lib/esm.mjs\n // but we need path/to/dist/cjs/cjs.js\n const base = getImportMetaURL('../cjs/[global preload].js')\n const { port } = context || {}\n PORT = port\n return `\nif (typeof port !== 'undefined') {\n const { createRequire } = getBuiltin('module')\n const { fileURLToPath } = getBuiltin('url')\n const require = createRequire(${JSON.stringify(base)})\n const { getProcessInfo } = require('./get-process-info.js')\n const { saveLineLengths } = require('./line-lengths.js')\n // must be called eagerly here.\n // this does all the registration as well.\n const processInfo = getProcessInfo()\n port.onmessage = (e) => {\n const { filename, content } = e.data\n processInfo.files.push(filename)\n saveLineLengths(filename, content)\n }\n port.unref()\n}\n`\n}\n\nexport const initialize = ({ port }: { port: MessagePort }) => {\n PORT = port\n}\n\nconst exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false)\n\nconst record = async (url: string, content?: string) => {\n const filename = url.startsWith('file://') ? fileURLToPath(url) : url\n if (exclude.test(filename)) {\n return\n }\n if (fakeMains.includes(filename)) {\n return\n }\n\n if (PORT) {\n PORT.postMessage({ filename, content })\n } else {\n // call lazily so we don't double-register\n getProcessInfo().files.push(filename)\n saveLineLengths(filename, content)\n }\n}\n\nexport const load = async (\n url: string,\n context: any,\n nextLoad: Function\n) => {\n if (url.startsWith('file://')) {\n const filename = fileURLToPath(url)\n const { ext } = parse(filename)\n // Package bins will sometimes have an extensionless bin script\n // instead of just naming their extensioned file and letting npm\n // symlink it for them. Don't blow up when this happens, just tell\n // node that it's commonjs.\n // TODO: should we just let this fail? It fails *without* the loader,\n // after all.\n if (!ext) {\n await record(url)\n return {\n ...context,\n format: 'commonjs',\n shortCircuit: true,\n }\n }\n }\n\n // we actually need the transpiled\n const ret = await nextLoad(url, context)\n await record(url, ret.source)\n return ret\n}\n\n// just for testing purposes\nexport const reset = () => {\n PORT = undefined\n getProcessInfo = processInfoReset().getProcessInfo\n}\n"]}
|