Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Fastify = require("fastify");
const { fastify } = require("fastify");
const { default: fastifiDefault } = require("fastify");
const { default: fastifyDefault } = require("fastify");

const fastify1 = Fastify();

Expand All @@ -26,7 +26,7 @@ fastify2
process.exit(1);
});

const fastify3 = fastifiDefault();
const fastify3 = fastifyDefault();

fastify2
.listen(3002)
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "",
"main": "index.js",
"scripts": {
"cjs": "node ./cjs",
"esm": "node ./esm/index.mjs",
"ts-interop-false": "tsc -p ./typescript/es-module-interop-false/tsconfig.json && node ./typescript/es-module-interop-false/build",
"ts-interop-true": "tsc -p ./typescript/es-module-interop-true/tsconfig.json && node ./typescript/es-module-interop-true/build",
"all": "run-p cjs esm ts-interop-false ts-interop-true"
"run:cjs": "node ./cjs",
"run:esm": "node ./esm/index.mjs",
"run:ts-interop-false": "tsc -p ./typescript/es-module-interop-false/tsconfig.json && node ./typescript/es-module-interop-false/build",
"run:ts-interop-true": "tsc -p ./typescript/es-module-interop-true/tsconfig.json && node ./typescript/es-module-interop-true/build",
"run:typed-cjs": "tsc -p ./typed-cjs/tsconfig.json && node ./cjs",
"all": "run-p run:*"
},
"repository": {
"type": "git",
Expand Down
39 changes: 39 additions & 0 deletions typed-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const Fastify = require("fastify");
const { fastify } = require("fastify");
const { default: fastifyDefault } = require("fastify");

const fastify1 = Fastify();

fastify1
.listen(3000)
.then(() => {
console.log(`[CJS] module.exports is running.`);
})
.catch((err) => {
console.log(err);
process.exit(1);
});

const fastify2 = fastify();

fastify2
.listen(3001)
.then(() => {
console.log(`[CJS] named require is running.`);
})
.catch((err) => {
console.log(err);
process.exit(1);
});

const fastify3 = fastifyDefault();

fastify2
.listen(3002)
.then(() => {
console.log(`[CJS] default property require is running.`);
})
.catch((err) => {
console.log(err);
process.exit(1);
});
11 changes: 11 additions & 0 deletions typed-cjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
},
"include": [
"./index.js"
]
}