0.12.0 • Published 2 months ago

@lit-labs/analyzer v0.12.0

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
2 months ago

@lit-labs/analyzer

A static analyzer for Lit

Overview

This package contains static analysis utilities for analyzing source code that contain Lit templates and elements, that might be useful for other programs like linters, IDE plugins, code generators, etc.

This is a very early stage Lit Labs package and is not ready for use.

Usage

This section is incomplete

Node

import {createPackageAnalyzer} from '@lit-labs/analyzer/package-analyzer.js';
import * as path from 'path';

const packagePath = path.resolve('./my-package');
const analyzer = createPackageAnalyzer(packagePath);
const module = analyzer.getModule(
  path.resolve(packagePath, 'src/my-element.ts')
);

Browser

You must use a bundler to bundle TypeScript, such as Rollup with the CommonJS plugin.

With @rollup/plugin-commonjs you need to ignore built-in libraries like os, fs, etc. You can isgnore these in your Rollup config:

rollup.config.js:

import commonjs from '@rollup/plugin-commonjs';

// ...
    plugins: [
      commonjs({
          ignore: (id) => ['fs', 'os', 'inspector'].includes(id),
      }),
    ],
// ...

You may need to install the 'path' package:

npm i path

Then you can make an Analyzer using these imports:

import {Analyzer} from '@lit-labs/analyzer/lib/analyzer.js';
import {AbsolutePath} from '@lit-labs/analyzer/lib/paths.js';
import ts from 'typescript';
import * as path from 'path';

// TODO: show constructing an Analyzer in browser contexts

Contributing

Please see CONTRIBUTING.md.

0.12.0

2 months ago

0.11.1

3 months ago

0.10.0

7 months ago

0.11.0

7 months ago

0.9.0

9 months ago

0.9.2

8 months ago

0.9.1

9 months ago

0.10.0-pre.0

8 months ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.1-pre.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.3.0

2 years ago

0.4.0

2 years ago

0.2.1

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago