-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for preloading ES module with --import flag (#713)
* feat: add support for preloading ES module with --import flag use --import or -i to preload ES module * docs: add docs for --import flag * fix: fix minor typos * docs: add the --import option to the start command usage file --------- Co-authored-by: Weixin Wu <[email protected]>
- Loading branch information
Showing
10 changed files
with
141 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
/* global GLOBAL_MODULE_1 */ | ||
/* global GLOBAL_MODULE_1, GLOBAL_MODULE_3 */ | ||
'use strict' | ||
const t = require('tap') | ||
|
||
module.exports = async function (fastify, options) { | ||
fastify.get('/', async function (req, reply) { | ||
return { hasPreloaded: GLOBAL_MODULE_1 } | ||
return { hasPreloaded: GLOBAL_MODULE_1 && GLOBAL_MODULE_3 } | ||
}) | ||
fastify.addHook('onReady', function () { | ||
t.ok(GLOBAL_MODULE_1) | ||
t.ok(GLOBAL_MODULE_3) | ||
}) | ||
} |
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
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,3 @@ | ||
/* global GLOBAL_MODULE_3 */ | ||
globalThis.GLOBAL_MODULE_3 = true // eslint-disable-line | ||
console.log('this is module to be preloaded that sets GLOBAL_MODULE_3=', GLOBAL_MODULE_3) |
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,3 @@ | ||
/* global GLOBAL_MODULE_4 */ | ||
globalThis.GLOBAL_MODULE_4 = true // eslint-disable-line | ||
console.log('this is module to be preloaded that sets GLOBAL_MODULE_4=', GLOBAL_MODULE_4) |
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