-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(js)!: initialize js/js package (#122)
- Loading branch information
Showing
8 changed files
with
187 additions
and
1 deletion.
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,11 @@ | ||
module.exports = { | ||
coveragePathIgnorePatterns: ['/node_modules/', '/lib/'], | ||
coverageReporters: ['text-summary', 'lcov'], | ||
moduleFileExtensions: ['ts', 'js'], | ||
setupFilesAfterEnv: ['./jest.setup.js'], | ||
testPathIgnorePatterns: ['lib'], | ||
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|js)$', | ||
transform: { | ||
'.ts': 'ts-jest', | ||
}, | ||
}; |
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,12 @@ | ||
// Need to disable following rules to mock text-decode/text-encoder and crypto for jsdom | ||
// https://github.com/jsdom/jsdom/issues/1612 | ||
/* eslint-disable @silverhand/fp/no-mutation */ | ||
/* eslint-disable unicorn/prefer-module */ | ||
const { Crypto } = require('@peculiar/webcrypto'); | ||
const fetch = require('node-fetch'); | ||
const { TextDecoder, TextEncoder } = require('text-encoder'); | ||
|
||
global.crypto = new Crypto(); | ||
global.fetch = fetch; | ||
global.TextDecoder = TextDecoder; | ||
global.TextEncoder = TextEncoder; |
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,48 @@ | ||
{ | ||
"name": "@logto/js", | ||
"version": "0.0.1", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"license": "MPL-2.0", | ||
"scripts": { | ||
"dev:tsc": "tsc -b -w --preserveWatchOutput", | ||
"preinstall": "npx only-allow pnpm", | ||
"precommit": "lint-staged", | ||
"build": "tsc", | ||
"lint": "eslint --ext .ts src", | ||
"package": "webpack", | ||
"test": "jest", | ||
"test:coverage": "jest --silent --coverage", | ||
"test:report": "codecov -F js", | ||
"prepublish": "npm run build && npm run package", | ||
"report": "WITH_REPORT=true npm run package" | ||
}, | ||
"dependencies": { | ||
"@silverhand/essentials": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"@peculiar/webcrypto": "^1.1.7", | ||
"@silverhand/eslint-config": "^0.5.0", | ||
"@silverhand/ts-config": "^0.5.0", | ||
"@types/jest": "^26.0.24", | ||
"@types/webpack": "^5.28.0", | ||
"codecov": "^3.8.3", | ||
"eslint": "^8.1.0", | ||
"jest": "^27.0.6", | ||
"lint-staged": "^11.1.2", | ||
"nock": "^13.1.3", | ||
"node-fetch": "2.6.6", | ||
"prettier": "^2.3.2", | ||
"text-encoder": "^0.0.4", | ||
"ts-jest": "^27.0.4", | ||
"ts-loader": "^9.2.6", | ||
"typescript": "^4.3.5", | ||
"webpack": "^5.58.2", | ||
"webpack-bundle-analyzer": "^4.5.0", | ||
"webpack-cli": "^4.9.1" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@silverhand/eslint-config" | ||
}, | ||
"prettier": "@silverhand/eslint-config/.prettierrc" | ||
} |
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,9 @@ | ||
// Temporary content, for `pnpm test` to pass CI, will be deleted later | ||
import { TODO } from '.'; | ||
|
||
describe('TODO', () => { | ||
test('TODO', async () => { | ||
const todo: TODO = 'todo'; | ||
expect(todo).toEqual(todo); | ||
}); | ||
}); |
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,4 @@ | ||
// Temporary content, for `pnpm build` to pass CI, will be deleted later | ||
import { Optional } from '@silverhand/essentials'; | ||
|
||
export type TODO = Optional<string>; |
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,10 @@ | ||
{ | ||
"extends": "@silverhand/ts-config/tsconfig.base", | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"target": "es5" | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
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,32 @@ | ||
const path = require('path'); | ||
|
||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); | ||
|
||
module.exports = () => { | ||
const { WITH_REPORT } = process.env; | ||
|
||
return { | ||
mode: 'production', | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'logto.min.js', | ||
library: { | ||
type: 'umd', | ||
name: 'logto', | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
exclude: /node_modules/, | ||
use: 'ts-loader', | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
}, | ||
plugins: WITH_REPORT ? [new BundleAnalyzerPlugin()] : [], | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.