npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hikaruna/pocket-monster

v0.0.1

Published

様々な環境から読み込めるライブラリを生成するexample

Downloads

1

Readme

様々な環境から読み込めるライブラリを生成するexample

  • nativeなnodeからの読み込みに対応(cjs/npm) → lib/index.js
  • esmを有効にしたnode、もしくは、webpackなどのバンドラからの読み込みに対応(esm/npm) → lib/index.mjs
  • レガシーブラウザからの読み込みに対応(umd) → dist/packet-monster.umd.js
  • モダンブラウザからの読み込みに対応(esm/cdn) → dist/lib/index.js

| dir | 説明 | | --- | --- | | . | | | ./dist | ブラウザなどnodejs向け以外の成果物 | | ./dist/lib | <script type="module">に対応したブラウザなど、nodejs以外のためのesm/cdnの成果物 | | ./lib | node.js向けの成果物 | | ./lib//*.js | node.js向けのcsjの成果物 | | ./lib//*.mjs | esModuleに対応したnode.jsやwebpackなど向けのesm/npmの成果物 | | ./src | ソースコード。sourceMapで参照される | | ./typings | 型情報。 node.js向けに型情報を提供、sourceMapも含んでいる |

Usage

モダンブラウザ

<monster-form></monster-form>

<script type="module">
  import { Monster, MonsterForm } from 'http://unpkg.com/@hikaruna/pocket-monster'
  // or
  // import Monster from 'http://unpkg.com/@hikaruna/pocket-monster/dist/lib/Monster.js'
  // import MonsterForm from 'http://unpkg.com/@hikaruna/pocket-monster/dist/lib/components/MonsterForm.js'

  const monster = new Monster({ name: "フシギダネ" });

  window.onload = () => {
    const monsterForm = document.querySelector('monster-form');
    monsterForm.monster = monster;
  }
</script>

レガシーブラウザ

<script src="http://unpkg.com/@hikaruna/pocket-monster/dist/pocket-monster.umd.js"></script>

<script>
  var monster = new pocketMonster.Monster({ name: "フシギダネ" });

  window.onload = function() {
    const monsterForm = document.querySelector('monster-form');
    monsterForm.monster = monster;
  }
</script>

node.js(esm), webpack等

$ npm i @hikaruna/pocket-monster
import { Monster } from '@hikaruna/pocket-monster'
// or
// import Monster from '@hikaruna/pocket-monster/lib/Monster'

const monster = new Monster({ name: "フシギダネ" });

node.js ネイティブ

$ npm i @hikaruna/pocket-monster
const { Monster } = require('@hikaruna/pocket-monster');
// or
// const Monster = require('@hikaruna/pocket-monster/lib/Monster');

const monster = new Monster({ name: "フシギダネ" });

Development

edit

src/**/*.tsを開発します

build

$ npm run buildでbuildを行います。

内部で行われていることは

$ tsc #=> src/ -> .build/
$ rollup -c #=> .build/ -> lib/ dist/

制限

直接利用する依存パッケージは、package.json記述する必要があります

依存パッケージは、package.jsonのdependency or peerDependencyに記述されている必要があります。 そうでない場合、esm/cdn形式に変換する際に、version: latestと認識されます。 cdnを利用しない形式の場合問題はありません。