Skip to content

Commit

Permalink
chore(vanillin): added new readme for core module
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schürmann committed Dec 27, 2024
1 parent c0c0abe commit 073605b
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
dist/
dist-my-circle/
etc
docs
docs
.DS_Store
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ test:
npm test -ws

docs:
typedoc --options ./packages/vanillin/typedoc.json --tsconfig ./packages/vanillin/tsconfig.json
npx typedoc --options ./packages/vanillin/typedoc.json --tsconfig ./packages/vanillin/tsconfig.json
79 changes: 79 additions & 0 deletions packages/vanillin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# vanillin

The core library of the Vanillin.js toolchain, providing essential utilities and runtime support for developing web components using vanilla JavaScript.

## Classes

### Compiler
The core TypeScript compilation engine that supports both standard and virtual filesystem operations. It provides:
- Flexible compilation with customizable compiler options
- Support for virtual filesystem compilation
- Built-in transformers for ES module compatibility
- Default configuration targeting modern browsers

### TestHelper
A powerful testing utility for web components that provides:
- JSDOM-based testing environment
- Component mounting and initialization
- Support for both pre-compiled and TypeScript components
- Customizable JSDOM options for specific testing needs

### ResultAnalyzer
Analyzes compilation results and provides detailed diagnostics:
- Error and warning categorization
- Formatted diagnostic messages
- Access to compiler output files
- Source file analysis capabilities

### VirtualCompilerHost
A TypeScript compiler host implementation using a virtual filesystem:
- In-memory file operations
- Isolation for testing and development
- Compatible with standard TypeScript compiler API
- Configurable working directory and file structure

## Usage

### Testing Components

```typescript
import { TestHelper } from 'vanillin';

const helper = new TestHelper();
const context = await helper.mountAsScript('my-component', componentCode);

// Access the mounted component
const component = context.querySelector('my-component');
```

### Virtual Filesystem

```typescript
import { createVirtualFs } from 'vanillin';

const fs = createVirtualFs({
'/src/component.ts': `
class MyComponent extends HTMLElement {
// component code
}
`
});
```

## API Reference

For detailed API documentation, please refer to the generated API documentation in the project root.

## Dependencies

- jsdom: ^25.0.1
- memfs: ^4.15.1
- typescript: ^5.7.2

## Contributing

This package is part of the Vanillin.js monorepo. Please refer to the main project's README for contribution guidelines.

## License

MIT © Sebastian Schürmann
22 changes: 0 additions & 22 deletions packages/vanillin/api-extractor.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/vanillin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@types/node": "22.10.2"
},
"dependencies": {
"@microsoft/api-extractor": "^7.48.1",
"jsdom": "25.0.1",
"memfs": "4.15.1",
"typescript": "5.7.2"
Expand Down

0 comments on commit 073605b

Please sign in to comment.