1.0.2 • Published 4 years ago

ts-bookmarklet v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

ts-bookmarklet

The code written in TypeScript is converted to URLs for bookmarklet and output.

TypeScriptで書かれたコードをブックマークレット用のURLに変換して出力します。

NPM version NPM monthly download NPM total download Build Status MIT License

On Windows, you can copy the URL for the bookmarklet to the clipboard by running the following.

Windowsでは、以下のように実行することで、ブックマークレット用のURLがクリップボードにコピーされます。

> npx ts-bookmarklet main.ts | clip

The JavaScript transpiled from TypeScript is further converted to a URL in a minified and mangled state by uglify-es.

TypeScriptからトランスパイルされたJavaScriptは、さらにuglify-esによりminifyされmangleされた状態でURLに変換されます。

Commandline Options - コマンドラインオプション

  • --tsconfig tsconfig.json | -t tsconfig.json
    typescriptのコンパイルに使用する設定を記述したファイルを指定します。
    省略時には一番最初のソースファイルと同じディレクトリにある
    tsconfig.jsonを指定したものと見なします。
    ディレクトリにtsconfig.jsonが見つからない場合には、
    以下の設定が指定されたものとしてコンパイルします。

    {
      "compilerOptions": {
        "target": "ES2018",
        "lib": [
          "ESNext",
          "DOM",
          "DOM.Iterable"
        ],
        "strict": true,
        "strictNullCheck": true,
        "alwaysStrict": false,
        "noImplicitUseStrict": true,
        "module": "none",
        "moduleResolution": "node"
      }
    }

    tsconfig.jsonを指定した場合でも、以下のオプションについては、
    設定されていなければTypeScriptのデフォルト値ではなく、
    以下の値が使用されます。

    {
      "compilerOptions": {
        "target": "ES2018",
        "strict": true,
        "strictNullChecks": true
      }
    }

    また、以下のオプションについては設定されていても
    以下の値で上書きされます。

    {
      "compilerOptions": {
        "alwaysStrict": false,
        "noImplicitUseStrict": true,
        "module": "none",
        "moduleResolution": "node"
      }
    }
  • --target ES3|ES5|ES2015|ES2016|ES2017|ES2018|ES2019|ES2020|ESNext
    出力するjavascriptのバージョンを指定します。
    たとえば、IE11でも使用できるようにするにはES5を指定します。

  • --no-scheme
    javascript:を出力しない場合に指定します。
  • スクリプトファイル
    複数指定した場合はすべてのファイルをマージした状態のブックマークレットを作成します。