![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
dev-novel is a clone of the well known storybook.js. It allows you to browse through example of a library. It's less complete than Storybook but works with every JS library, it's not linked to React components exclusively.
$ npm i -D dev-novel
OR$ yarn add -D dev-novel
You will need your own build system (like webpack or rollup) to process the javascript and serve the page for you. You need to serve an index.html
with a body tag and voilà!
import { storiesOf } from 'dev-novel'
storiesOf('My first story')
.add('Hello world', (container: HTMLDivElement) => {
// create `<h1>Hello world</h1>`
const title = document.createElement('h1')
title.innerText = 'Hello world'
// display it into the story result
container.appendChild(title)
})
This can be useful when you need to provide globals for your story, for instance depending onto another library.
import { registerInitializer, registerDisposer, storiesOf } from 'dev-novel'
registerInitializer(() => {
window._appState = {
user: {
firstName: 'Max',
lastName: 'Tyler'
}
}
})
registerDisposer(() => {
window._appState = undefined
delete window._appState
})
storiesOf('User profile')
.add('Display user fullname', (container: HTMLDivElement) => {
const span = document.createElement('span')
span.innerText = `${window._appState.user.firstName} ${window._appState.user.lastName}`
container.appendChild(span)
})
import { start, storiesOf } from 'dev-novel'
[...]
start({
projectName: ?string // name of the project to display in header of sidebar
projectLink: ?string // URL to link on the projectName
openAllStories?: boolean // open all parent stories item in the menu by default
})
With actions, you can inspect events and log them directly into the page. This is pretty neat when you are manually testing your components.
import { action, registerDisposer, storiesOf } from 'dev-novel'
// remove all event listeners when switching to another story
let eventDisposers = []
registerDisposer(() => {
eventDisposers.forEach(disposer => disposer())
eventDisposers = []
})
storiesOf('Button')
.add('click', container => {
const handler = action('button-click')
const button = document.createElement('button')
button.innerText = 'Click me!'
button.addEventListener('click', handler, false)
// remove event listener after story ran
const disposer = () => button.removeEventListener('click', handler, false)
eventDisposers.push(disposer)
// append button
container.appendChild(button)
})
FAQs
📓 Build an interactive JavaScript development page
The npm package dev-novel receives a total of 1 weekly downloads. As such, dev-novel popularity was classified as not popular.
We found that dev-novel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.