JSPM

cem-plugin-readonly

0.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 781
  • Score
    100M100P100Q101556F
  • License MIT

Readonly fields

Package Exports

  • cem-plugin-readonly
  • cem-plugin-readonly/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cem-plugin-readonly) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cem-plugin-readonly

Adds (non-standard) "readonly" flag to class fields

Example

custom-elements-manifest.config.js

import { readonlyPlugin } from 'cem-plugin-readonly';

export default {
  plugins: [
    readonlyPlugin(),
  ]
}

read-only.ts

/** @element read-only */
export class ReadOnly {
  static get x() { return 'x'; }
  static readonly y = 'y';
  /** @readonly */
  static z = 'z';
  readonly x = 'x';
  get y() { return 'y'; }
  /** @readonly */
  z = 'z';
}

Output

{
  "schemaVersion": "1.0.0",
  "readme": "",
  "modules": [
    {
      "kind": "javascript-module",
      "path": "read-only.js",
      "declarations": [
        {
          "kind": "class",
          "description": "",
          "name": "ReadOnly",
          "members": [
            {
              "kind": "field",
              "name": "x",
              "readonly": true,
              "type": {
                "text": "string"
              }
            },
            {
              "kind": "field",
              "name": "y",
              "readonly": true,
              "type": {
                "text": "string"
              }
            },
            {
              "kind": "field",
              "name": "z",
              "readonly": true,
              "type": {
                "text": "string"
              }
            }
          ],
          "tagName": "read-only",
          "customElement": true
        }
      ],
      "exports": [
        {
          "kind": "js",
          "name": "ReadOnly",
          "declaration": {
            "name": "ReadOnly",
            "module": "read-only.js"
          }
        }
      ]
    }
  ]
}