| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,6 +67,21 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 67 | 67 | assert.strictEqual(code, 0); | |
| 68 | 68 | assert.strictEqual(signal, null); | |
| 69 | 69 | }); | |
| 70 | + | ||
| 71 | + it('import.meta.resolve of a never-settling resolve', async () => { | ||
| 72 | + const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ | ||
| 73 | + '--no-warnings', | ||
| 74 | + '--experimental-import-meta-resolve', | ||
| 75 | + '--experimental-loader', | ||
| 76 | + fixtures.fileURL('es-module-loaders/never-settling-resolve-step/loader.mjs'), | ||
| 77 | + fixtures.path('es-module-loaders/never-settling-resolve-step/import.meta.never-resolve.mjs'), | ||
| 78 | + ]); | ||
| 79 | + | ||
| 80 | + assert.strictEqual(stderr, ''); | ||
| 81 | + assert.match(stdout, /^should be output\r?\n$/); | ||
| 82 | + assert.strictEqual(code, 13); | ||
| 83 | + assert.strictEqual(signal, null); | ||
| 84 | + }); | ||
| 70 | 85 | }); | |
| 71 | 86 | ||
| 72 | 87 | describe('should handle never-settling hooks in CJS files', { concurrency: true }, () => { | |
@@ -165,4 +180,19 @@ describe('Loader hooks', { concurrency: true }, () => { | |||
| 165 | 180 | assert.strictEqual(code, 1); | |
| 166 | 181 | assert.strictEqual(signal, null); | |
| 167 | 182 | }); | |
| 183 | + | ||
| 184 | + it('should not leak internals or expose import.meta.resolve', async () => { | ||
| 185 | + const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ | ||
| 186 | + '--no-warnings', | ||
| 187 | + '--experimental-import-meta-resolve', | ||
| 188 | + '--experimental-loader', | ||
| 189 | + fixtures.fileURL('es-module-loaders/loader-edge-cases.mjs'), | ||
| 190 | + fixtures.path('empty.js'), | ||
| 191 | + ]); | ||
| 192 | + | ||
| 193 | + assert.strictEqual(stderr, ''); | ||
| 194 | + assert.strictEqual(stdout, ''); | ||
| 195 | + assert.strictEqual(code, 0); | ||
| 196 | + assert.strictEqual(signal, null); | ||
| 197 | + }); | ||
| 168 | 198 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + import { strictEqual } from "node:assert"; | ||
| 2 | + import { isMainThread, workerData, parentPort } from "node:worker_threads"; | ||
| 3 | + | ||
| 4 | + // TODO(aduh95): switch this to `false` when loader hooks are run on a separate thread. | ||
| 5 | + strictEqual(isMainThread, true); | ||
| 6 | + | ||
| 7 | + // We want to make sure that internals are not leaked on the public module: | ||
| 8 | + strictEqual(workerData, null); | ||
| 9 | + strictEqual(parentPort, null); | ||
| 10 | + | ||
| 11 | + // TODO(aduh95): switch to `"undefined"` when loader hooks are run on a separate thread. | ||
| 12 | + // We don't want `import.meta.resolve` being available from loaders | ||
| 13 | + // as the sync implementation is not compatible with calling async | ||
| 14 | + // functions on the same thread. | ||
| 15 | + strictEqual(typeof import.meta.resolve, 'function'); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + console.log('should be output'); | ||
| 2 | + | ||
| 3 | + await import.meta.resolve('never-settle-resolve'); | ||
| 4 | + | ||
| 5 | + console.log('should not be output'); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments