# websdk

> Web SDK is a set of conventions and code to provide modularity and lazy loading for web components and libraries under a unified and simplified build approach through webpack

Latest version **3.0.0** (published 2017-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install websdk
pnpm add websdk
yarn add websdk
bun add websdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2017-08-23 |
| First published | 2017-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 43 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Julio Stanley |
| Maintainers | juliostanley |
| Keywords | websdk, web, sdk, polymer, webpack, build, frontend, javascript, es2015, es6, progressive, progressive web apps |

## Links

- npm: https://www.npmjs.com/package/websdk
- Repository: https://github.com/juliostanley/websdk
- Homepage: https://juliostanley.github.io/websdk
- Issues: https://github.com/juliostanley/websdk/issues
- npm.io page: https://npm.io/package/websdk

## Dependencies (43)

- [less](https://npm.io/package/less.md) 2.7.2
- [chalk](https://npm.io/package/chalk.md) 1.1.3
- [debug](https://npm.io/package/debug.md) 2.2.0
- [eslint](https://npm.io/package/eslint.md) 3.19.0
- [lesshat](https://npm.io/package/lesshat.md) 4.1.0
- [webpack](https://npm.io/package/webpack.md) 2.6.1
- [optimist](https://npm.io/package/optimist.md) 0.6.1
- [progress](https://npm.io/package/progress.md) 2.0.0
- [node-sass](https://npm.io/package/node-sass.md) 4.5.3
- [babel-core](https://npm.io/package/babel-core.md) 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc
- [css-loader](https://npm.io/package/css-loader.md) 0.28.4
- [protobufjs](https://npm.io/package/protobufjs.md) 6.7.3
- [raw-loader](https://npm.io/package/raw-loader.md) 0.5.1
- [source-map](https://npm.io/package/source-map.md) 0.5.6
- [url-loader](https://npm.io/package/url-loader.md) 0.5.8
- [file-loader](https://npm.io/package/file-loader.md) 0.11.1
- [html-loader](https://npm.io/package/html-loader.md) 0.4.5
- [json-loader](https://npm.io/package/json-loader.md) 0.5.4
- [less-loader](https://npm.io/package/less-loader.md) 4.0.4
- [noop-loader](https://npm.io/package/noop-loader.md) 1.0.0
- [sass-loader](https://npm.io/package/sass-loader.md) 6.0.5
- [yaml-loader](https://npm.io/package/yaml-loader.md) 0.4.0
- [babel-loader](https://npm.io/package/babel-loader.md) 7.0.0
- [loader-utils](https://npm.io/package/loader-utils.md) 1.1.0
- [node-bourbon](https://npm.io/package/node-bourbon.md) 4.2.3
- [proto-loader](https://npm.io/package/proto-loader.md) 0.2.0
- [strip-loader](https://npm.io/package/strip-loader.md) 0.1.2
- [style-loader](https://npm.io/package/style-loader.md) 0.18.1
- [whatwg-fetch](https://npm.io/package/whatwg-fetch.md) 2.0.3
- [eslint-loader](https://npm.io/package/eslint-loader.md) 1.7.1
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc
- [compass-mixins](https://npm.io/package/compass-mixins.md) 0.12.10
- [exports-loader](https://npm.io/package/exports-loader.md) 0.6.4
- [imports-loader](https://npm.io/package/imports-loader.md) 0.7.1
- [@polymer/polymer](https://npm.io/package/@polymer/polymer.md) 3.0.0 || ^3.0.0-pre
- [babel-preset-env](https://npm.io/package/babel-preset-env.md) 2 || ^2.0.0-alpha || ^2.0.0-beta || ^2.0.0-rc
- [resolve-url-loader](https://npm.io/package/resolve-url-loader.md) 2.0.2
- [@webcomponents/shadycss](https://npm.io/package/@webcomponents/shadycss.md) 1.0.5
- [webpack-bundle-analyzer](https://npm.io/package/webpack-bundle-analyzer.md) 2.9.0
- [extract-text-webpack-plugin](https://npm.io/package/extract-text-webpack-plugin.md) 2.1.0
- [@webcomponents/webcomponentsjs](https://npm.io/package/@webcomponents/webcomponentsjs.md) 1.0.8
- [directory-named-webpack-plugin](https://npm.io/package/directory-named-webpack-plugin.md) 2.1.0
- [amd-define-factory-patcher-loader](https://npm.io/package/amd-define-factory-patcher-loader.md) 1.0.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2017-08-23

## README

# Web SDK

[![Circle CI](https://circleci.com/gh/juliostanley/websdk-samples.svg?style=svg)](https://circleci.com/gh/juliostanley/websdk-samples)

> See some sample usage at https://github.com/juliostanley/websdk-custom-elements/ and https://github.com/juliostanley/websdk-samples/

The websdk is a library to ease the creation of progressive web apps. Eases the usage of latest ES features and Web Components.

With ES import/export, web components and a data binding preference (Polymer or Redux Adapter), you can replace most of the common "frameworks".

Using **websdk** and **npm scripts** you can replace most/all of the needs for **grunt**, **gulp**, **vulcanize** and **crisp**. It uses **babel** to enable ES2015 features even for you polymer web components as ES Classes

The project is possible thanks to many other great libraries, look at *package.json* dependencies.

Features:
- Simple build system (based on webpack):
- Lazy load webpack modules through webpack
- Declerative imports **<ensure-import>**
- Allows for incremental migration between frameworks
- **build** Not opinionated in terms of directory structure
- **build** Minification of your files when running --env prod flag
- **build** Bundling of files
- **build** Use npm or yarn

### Suggestion

On large applications, use redux, polymer and polymer-redux. Use redux-observable for complex state flow.

### How to use

```
npm install websdk
npm install live-server # Not required, only for demo purpose
```

Create **./your-build.js**
```
// build.config will be the webpack config
// Access to rules object through build.rules. Object.keys(build.rules)
// Access to plugins object through build.plugins. Object.keys(build.plugins)

var build = require('websdk/build');
build.config.output.publicPath = '/artifacts/'; // Server url path
build.config.entry.style = __dirname + '/any/file/for.css'; // Or less or sass/scss
build.config.entry.start = __dirname + '/any/file/for.js'; // JavaScript
build.run();
```

Run your build with
```
node ./your-build.js --od=artifacts --w
```

Create an **./index.html**
```
<!DOCTYPE html><html><head></head><body>
<script src="artifacts/style.bundle.js"></script>
<script src="artifacts/start.bundle.js"></script>
</body></html>
```

Run your server
```
live-server .
```

### FAQs
- **Why use javascript for css?** To not block rendering (some browsers still block when using link tags), you can deliver a spinner while base styles load

- **Can I customize the webpack config?** Yes. Its all under build.config, change it before executing build.run()

- **I would like stats on my build** Run your build with the flag ```--profile``` and upload it to [Webpack Analyse](https://webpack.github.io/analyse/)

- **Can I load paper elements?** Yes. Just load it on your .js file with ES, CommonJS or AMD: ```import 'paper-input/paper-input.html';```, ```require('paper-input/paper-input.html');```, it will be ready for use on your page

- **Does this support ES2015/ES6** Yes. By default it uses babel on any module under **app_modules**

- **Under what directory should I store my code** A directory named **app_modules**, this will act like if they were in **node_modules** or **web_modules**

- **How do I separate my app into multiple bundles** Refer to the [Samples](https://circleci.com/gh/juliostanley/websdk-samples)

- **...sooo my gulp/grunt task manager?** For the most not needed, use npm scripts to run commands  ```npm run <command>```

### Suggested commands for package.json
```
"scripts": {
  ,"start"              : "live-server --path=./gui"
  ,"build"              : "node ./tools/build.js --od ./gui/artifacts"
  ,"build:some"         : "node ./tools/build.js --od ./gui/artifacts --sc some,maybeother"
  ,"build:help"         : "node ./tools/build.js --help"
  ,"build:profile"      : "node ./tools/build.js --od ./gui/artifacts --pf"
  ,"build:watch"        : "node ./tools/build.js --od ./gui/artifacts --w"
  ,"build:watch:dist"   : "node ./tools/build.js --od ./gui/artifacts --w --env prod --kl"
  ,"build:watch:css"    : "node ./tools/build.js --od ./gui/artifacts --w --env prod --smcss"
  ,"build:watch:raw"    : "node ./tools/build.js --od ./gui/artifacts --w --devtool="
  ,"build:debug"        : "node ./tools/build.js --od ./gui/artifacts --w --env prod --kl --sm"
  ,"build:debug:css"    : "node ./tools/build.js --od ./gui/artifacts --w --env prod --kl --sm --smcss"
  ,"build:dist"         : "node ./tools/build.js --od ./gui/artifacts --env prod"
  ,"sdk:link"           : "rimraf ./node_modules/websdk && cd ./node_modules && sudo cmd /c mklink /D websdk ..\\app_modules\\websdk"
  ,"deps"               : "npm list --depth=0"
  ,"git:nicer"          : "git config diff.submodule log"
}
```

### Things to notice or not obvious in the samples

- The build supports chunks by using ```build.extraConfig.websdk.lib = {name:'path'}```

- Chunks can be loaded async using ```<ensure-import name=""><component-toload></component-toload></ensure>```

- Changes to files take around one second since webpack only needs to do partial rebuilds when watching files

- The build supports source maps and complete minification (should even work for HTML imports)

---
_Source: https://npm.io/package/websdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
