Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add browser build #8

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ typings/
# Build folders
lib/
deno/
dist/
*.sqlite
159 changes: 83 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions packages/hooks/build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');

module.exports = {
entry: './src/index.ts',
mode: 'production',
output: {
library: 'hooks',
libraryTarget: 'umd',
globalObject: 'this',
path: path.resolve(__dirname, '..', 'dist'),
filename: 'hooks.js'
},
resolve: {
extensions: ['.ts', '.js', '.json']
},
module: {
rules: [
{ test: /\.tsx?$/, use: ['ts-loader'], exclude: /node_modules/ }
]
}
}
8 changes: 7 additions & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
"main": "lib/",
"types": "lib/",
"scripts": {
"build:browser": "webpack --config build/webpack.config.js",
"build:deno": "shx mkdir -p deno && node build/deno",
"compile": "shx rm -rf lib/ && tsc",
"build": "npm run compile && npm run build:deno",
"build": "npm run compile && npm run build:deno && npm run build:browser",
"prepublish": "npm run build",
"test": "mocha --opts ../../mocha.opts --recursive test/**.test.ts test/**/*.test.ts"
},
Expand All @@ -47,5 +48,10 @@
"shx": "^0.3.2",
"ts-node": "^8.5.4",
"typescript": "^3.7.4"
},
"dependencies": {
"ts-loader": "^6.2.1",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
}
}
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ To a function or class without having to change its original code while also kee
- [Installation](#installation)
- [Node](#node)
- [Deno](#deno)
- [Browser](#browser)
- [Quick Example](#quick-example)
- [JavaScript](#javascript)
- [TypeScript](#typescript)
Expand Down Expand Up @@ -62,6 +63,16 @@ import { hooks } from 'https://unpkg.com/@feathersjs/hooks@latest/deno/index.ts'

> __Note:__ You might want to replace `latest` with the actual version you want to use (e.g. `https://unpkg.com/@feathersjs/hooks@^0.2.0/deno/index.ts`)

## Browser

`@feathersjs/hooks` is compatible with any module loader like Webpack and can be included in the browser directly via:

```html
<script type="text/javascript" src="//unpkg.com/@feathersjs/hooks@^0.2.0/dist/hooks.js"></script>
```

Which will make a `hooks` global variable available.

# Quick Example

## JavaScript
Expand Down