-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mock): add "type": "module" as default,for support esm
- Loading branch information
1 parent
e616e6f
commit 593854e
Showing
30 changed files
with
285 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
const { commandHttpCli } = require('../lib/index.cjs'); | ||
const { version } = require('../package.json'); | ||
|
||
commandHttpCli(version); |
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,5 +1,8 @@ | ||
#!/usr/bin/env node | ||
const { commandHttpCli } = require('../lib/index.cjs'); | ||
import { createRequire } from 'node:module'; | ||
import { commandHttpCli } from '../lib/index.js'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const { version } = require('../package.json'); | ||
|
||
commandHttpCli(version); |
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
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 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
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,14 @@ | ||
import type { ISocketDefaultController } from '@liangskyli/mock'; | ||
|
||
const socketDefaultController: ISocketDefaultController = (socket) => { | ||
const data = { a: 112 }; | ||
// 数据发送客户端 | ||
socket.emit('toClient', data); | ||
|
||
// 接收客户端数据 | ||
socket.on('toServer', (clientData) => { | ||
console.log('from client default namespace:', clientData); | ||
}); | ||
}; | ||
|
||
export default socketDefaultController; |
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 |
---|---|---|
|
@@ -20,12 +20,21 @@ | |
}, | ||
"license": "MIT", | ||
"author": "liangsky <[email protected]>", | ||
"main": "./lib/index.cjs.js", | ||
"module": "./lib/index.esm.js", | ||
"type": "module", | ||
"main": "./lib/index.cjs", | ||
"module": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"typings": "./lib/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./index.d.ts", | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.cjs" | ||
} | ||
}, | ||
"bin": { | ||
"mock-server": "./bin/index.js" | ||
"mock-server": "./bin/index.js", | ||
"mock-server-cjs": "./bin/index.cjs" | ||
}, | ||
"files": [ | ||
"lib", | ||
|
@@ -37,9 +46,14 @@ | |
"package.json" | ||
], | ||
"scripts": { | ||
"build": "rollup --bundleConfigAsCjs --config=./rollup.config.js", | ||
"start": "cross-env DEBUG=mock:utils cross-env TS_NODE_PROJECT=test/tsconfig.json node -r ts-node/register test/server.ts", | ||
"test-http-cli": "cross-env DEBUG=mock:utils node bin/index.js -d ./test -e mock/b.ts -c ./test/mock.config.ts", | ||
"build": "rollup --config=./rollup.config.js", | ||
"start-esm": "cross-env DEBUG=mock:* cross-env TS_NODE_PROJECT=test/esm/tsconfig.json node --loader ts-node/esm test/esm/server.ts", | ||
"start-esm-mock": "cross-env DEBUG=mock:* cross-env TS_NODE_PROJECT=test/esm/tsconfig.json node --loader ts-node/esm test/esm/server-mock-esm.ts", | ||
"start": "cross-env DEBUG=mock:* cross-env TS_NODE_PROJECT=test/tsconfig.json node -r ts-node/register test/server.ts", | ||
"test-http-cli": "cross-env DEBUG=mock:* node bin/index.js -d ./test -e mock/b.ts -c ./test/mock.config.ts", | ||
"test-http-cli-esm-config": "cross-env DEBUG=mock:* node bin/index.js -d ./test -e mock/b.ts -c ./test/esm/mock.config.ts", | ||
"test-http-cli-esm-mock": "cross-env DEBUG=mock:* node bin/index.js -e mock/b.ts -c ./test/esm/mock-esm.config.ts", | ||
"test-http-cli-cjs": "cross-env DEBUG=mock:* node bin/index.cjs -d ./test -e mock/b.ts -c ./test/mock.config.ts", | ||
"test:middleware": "cross-env TS_NODE_PROJECT=test/tsconfig.json node -r ts-node/register test/middleware.ts", | ||
"test:webpack-middleware": "cross-env TS_NODE_PROJECT=test/tsconfig.json node -r ts-node/register test/webpack-middleware.ts", | ||
"update:deps": "pnpm update --interactive --latest" | ||
|
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,4 +1,6 @@ | ||
import { getConfig } from '../rollup.base.config'; | ||
import packageJSON from './package.json'; | ||
import { createRequire } from 'node:module'; | ||
import { getConfig } from '../rollup.base.config.js'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const packageJSON = require('./package.json'); | ||
export default [getConfig(packageJSON)]; |
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
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,21 @@ | ||
import { defineConfig } from '@liangskyli/mock'; | ||
|
||
export default defineConfig({ | ||
//mockDir: path.join(curDirName, '../'), | ||
//mockDir: path.join(__dirname, '/gen-mock'), | ||
//mockDir: path.join(__dirname, '../../http-mock-gen/test/all-gen-dirs/gen-mock/'), | ||
port: 8002, | ||
socketConfig: { | ||
enable: true, | ||
opts: { | ||
path: '/socket.io/', | ||
cors: { | ||
origin: ['http://localhost:63342'], | ||
}, | ||
}, | ||
//mockControllerUrl: path.join(__dirname, '/mock/socket/sock.ts'), | ||
//mockControllerUrl: 'mock/socket/sock.ts', | ||
//mockControllerUrl: 'mock/socket/sock2.js', | ||
mockControllerUrl: 'mock/socket/sock3.ts', | ||
}, | ||
}); |
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,25 @@ | ||
import { defineConfig } from '@liangskyli/mock'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
const curDirName = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
export default defineConfig({ | ||
mockDir: path.join(curDirName, '../'), | ||
//mockDir: path.join(__dirname, '/gen-mock'), | ||
//mockDir: path.join(__dirname, '../../http-mock-gen/test/all-gen-dirs/gen-mock/'), | ||
port: 8002, | ||
socketConfig: { | ||
enable: true, | ||
opts: { | ||
path: '/socket.io/', | ||
cors: { | ||
origin: ['http://localhost:63342'], | ||
}, | ||
}, | ||
//mockControllerUrl: path.join(__dirname, '/mock/socket/sock.ts'), | ||
//mockControllerUrl: 'mock/socket/sock.ts', | ||
//mockControllerUrl: 'mock/socket/sock2.js', | ||
mockControllerUrl: 'mock/socket/sock3.ts', | ||
}, | ||
}); |
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 @@ | ||
{ | ||
"type": "module" | ||
} |
Oops, something went wrong.