Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ESM] always load the ESM loader (#279)
* [ESM] always load the ESM loader * Enable esmodule tests on Windows * Suppress ExperimentalWarning messages
- Loading branch information
Showing
11 changed files
with
74 additions
and
71 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createRequire } from 'module'; | ||
import { fileURLToPath } from 'url'; | ||
import { send } from './ipc.mjs'; | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
export async function getFormat(url, context, defaultGetFormat) { | ||
const getPackageType = require('get-package-type'); | ||
const filePath = fileURLToPath(url); | ||
|
||
send({ required: filePath }); | ||
try { | ||
return await defaultGetFormat(url, context, defaultGetFormat); | ||
} catch (err) { | ||
if (err.code === 'ERR_UNKNOWN_FILE_EXTENSION') { | ||
return { format: await getPackageType(filePath) }; | ||
} | ||
throw err; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createRequire } from 'module'; | ||
import { fileURLToPath } from 'url'; | ||
import { send } from './ipc.mjs'; | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
export async function load(url, context, defaultLoad) { | ||
const getPackageType = require('get-package-type'); | ||
const filePath = fileURLToPath(url); | ||
|
||
send({ required: filePath }); | ||
try { | ||
return await defaultLoad(url, context, defaultLoad); | ||
} catch (err) { | ||
if (err.code === 'ERR_UNKNOWN_FILE_EXTENSION') { | ||
return { format: await getPackageType(filePath), source: null }; | ||
} | ||
throw err; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { emitWarning } = process; | ||
|
||
process.emitWarning = (warning, ...args) => { | ||
if (args[0] === 'ExperimentalWarning') { | ||
return; | ||
} | ||
|
||
if (args[0] && typeof args[0] === 'object' && args[0].type === 'ExperimentalWarning') { | ||
return; | ||
} | ||
|
||
return emitWarning(warning, ...args); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters