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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
dist
.env
.npmrc
coverage
.env
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.vscode
**/*.spec.js
**/*.spec.ts
**/*.ts
!**/*.d.ts
coverage
.env
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"orta.vscode-jest",
"vitest.explorer",
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker"
]
Expand Down
20 changes: 19 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@
"LICENSE": true,
"tsconfig.*": true,
"node_modules": true,
"*.code-workspace": true
"*.code-workspace": true,
"*.config.ts": true,
"coverage": true
},
"search.exclude": {
".*": false,
"*.json": false,
"CODEOWNERS": false,
"dist": false,
"README.md": false,
"LICENSE": false,
"tsconfig.*": false,
"node_modules": false,
"*.code-workspace": false,
"*.config.ts": false,
"coverage": false
},
"files.insertFinalNewline": true,
"editor.tabSize": 2,
Expand All @@ -30,16 +45,19 @@
"cryptly",
"flagly",
"gracely",
"isly",
"isoly",
"langly",
"paramly",
"persistly",
"selectivly",
"servly",
"servly-azure",
"sessionly",
"smoothly",
"tidily",
"transactly",
"typedly",
"uply"
]
}
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
# library-template
Template for Typescript library.

## Configuration files
### `package.json`
Important fields in this file

#### `"type"`
Should be set to `"module"`. Modules are the future.

#### `"exports"`
Exports define which file should be imported when the module is imported. each import path can be split up into an `import` field and a `require` field. `import` points to the ESM entry and `require` points to the CJS entry.

#### `"main"`
Included for legacy reasons. Export field has priority for consumers supporting it. This points to the main entry for users importing via `require`

#### `"module"`
A widespread unofficial field included for legacy and bundler reasons. Many bundlers might still look for this field. This points to the main entry for users importing via `import`

#### `"types"`
Included for legacy reasons. Types defined by exports field should have priority but there types will be used by consumers using the `main` and `module` fields.

---

### `vite.config.ts`
Test environment configuration. Some libraries might need to be included in this configs `test.server.deps.inline` field for tests to not crash (like jest ignoreTransform patterns).

---

### `tsconfig.json`
Base configuration file. Contains configuration for building and running in test environment.
If more types are added to the `"types"` field in here make sure to update the other tsconfig files as well.

---

### `tsconfig.mjs.json`
Extends the base configuration file and excludes configuration related to the test environment.
If more types are added to the `"types"` field in here make sure to update the other tsconfig files as well.

---

### `tsconfig.cjs.json`
Extends the base configuration file and excludes configuration related to the test environment.
If more types are added to the `"types"` field in here make sure to update the other tsconfig files as well.
3 changes: 1 addition & 2 deletions index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "jest"
import * as library from "./index"
import { library } from "./index"

describe("library", () => {
it("a", () => {
Expand Down
4 changes: 3 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const a = 42
export namespace library {
export const a = 42
}
Loading
Loading