Skip to content
Open
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
10 changes: 6 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"plugins": [
"transform-function-bind",
"transform-object-rest-spread",
"transform-es2015-modules-commonjs"
"presets": [
["@babel/preset-env", {
"targets": {
"node": "10"
}
}]
]
}
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ the processed file available via a static route.
'client_js': {
'babel': {}, // Babel specific options. Defaults to the project .babelrc file options
'watchify': true, // Whether to have webpack watch for changes - add your js to .nxusrc 'ignore' if so
'minify': true, // Whether to have webpack minify output
'minify': undefined, // Whether to have webpack minify output
'sourceMap': 'cheap-module-eval-source-map', // Sourcemap devtool option for webpack
'webpackConfig': {}, // Additional webpack config, merged with default.
'appendRulesConfig': false, // should webpack config rules be merged or replace the default
Expand All @@ -32,6 +32,14 @@ the processed file available via a static route.
'buildSeries': false // Whether to run bundle builds in series instead of parallel, for deploy scripts
}

## Version Compatibilities

ClientJS works with Webpack v5, Babel v7 and Node.js v16.

It should be possible to get it to work with Node.js >=14.15.0
(a `babel-loader` requirement) and npm v7 (there's an npm v6 bug
that causes problems with Webpack).

## Usage

ClientJS currently supports bundling scripts from a JS file entry point or Polymer web components
Expand Down Expand Up @@ -73,49 +81,44 @@ You will need to install the necessary Babel presets and plugins
in your application, and add Babel configuration options to the
`clientjs` section of your `.nxusrc` file. For example:

```javascript
npm install --save babel-preset-es2015 \
babel-plugin-transform-function-bind \
babel-plugin-transform-object-rest-spread
```

"client_js": {
...
"babel": {
"presets": [ "es2015" ],
"plugins": [
"transform-function-bind",
"transform-object-rest-spread"
]
}
}
npm install --save @babel/preset-env
npm install --save @babel/plugin-proposal-function-bind

"client_js": {
...
"babel": {
"presets": [ "@babel/preset-env" ],
"plugins": [ "@babel/plugin-proposal-function-bind" ]
}
}

### includeScript

Injects the passed script entry into to the specified template after webpack/babel

**Parameters**
#### Parameters

- `templateName` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the template to include the script into
- `script` **\[type]** the path of the script file to include
* `templateName` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the template to include the script into
* `script` **\[type]** the path of the script file to include

### includeComponent

**Parameters**
#### Parameters

- `templateName` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the template to include the script into
- `script` **\[type]** the path of the component file to include
* `templateName` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the template to include the script into
* `script` **\[type]** the path of the component file to include

**Meta**

- **deprecated**: (Deprecated, includeScript now handles this.) Injects the passed web component entry into to the specified template after bundling/babel

* **deprecated**: (Deprecated, includeScript now handles this.) Injects the passed web component entry into to the specified template after bundling/babel

### bundle

Create a clientjs bundle that can be injected into a rendered page.

**Parameters**
#### Parameters

* `entry` **\[type]** the source file to bundle
* `output` **\[type]** the output path to use in the browser to access the bundled source

- `entry` **\[type]** the source file to bundle
- `output` **\[type]** the output path to use in the browser to access the bundled source
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise that resolves when bundling is completed
38 changes: 16 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
"name": "nxus-clientjs",
"version": "4.2.0",
"description": "Client JS compilation for Nxus applications",
"main": "lib/",
"main": "lib/index.js",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"preversion": "npm test",
"postversion": "npm run build-docs && git push && git push --tags",
"test": "NODE_ENV=test mocha --compilers js:babel-register -R spec src/test",
"test": "NODE_ENV=test mocha --require @babel/register --reporter spec src/test",
"compile": "rm -rf lib/; babel src --ignore src/test --out-dir lib",
"prepare": "npm run compile",
"prepublish": "npm run compile",
"postpublish": "npm run build-docs && npm run publish-docs",
"build-docs": "export NAME=`npm view . name`; export VERSION=`npm view . version`; documentation readme ./src/index.js --name $NAME --project-version $VERSION --readme-file ./README.md -s $NAME",
"build-docs": "NAME=\"${NAME:-$npm_package_name}\" VERSION=\"${VERSION:-$npm_package_version}\" && documentation readme ./src/index.js --project-name ${NAME} --project-version ${VERSION} --section ${NAME} --format md --markdown-toc false",
"publish-docs": "npm run build-docs && git add ./README.md && git commit -m 'Updated README API Docs' && git push"
},
"repository": {
Expand All @@ -29,37 +33,27 @@
},
"homepage": "https://github.com/nxus/clientjs",
"dependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"bluebird": "^3.0.6",
"@babel/core": "^7.21.3",
"babel-loader": "^9.1.2",
"css-loader": "^3.2.0",
"fs-extra": "^3.0.1",
"imports-loader": "^0.7.1",
"morph": "^0.2.0",
"nxus-core": "^4.0.0",
"nxus-router": "^4.0.0",
"nxus-templater": "^4.0.0",
"only-if-changed-webpack-plugin": "https://github.com/vhadianto/only-if-changed-webpack-plugin.git",
"polymer-webpack-loader": "^2.0.0",
"polymer-webpack-loader": "github:Banno/polymer-webpack-loader#c89f4a4",
"rc": "^1.1.6",
"script-loader": "^0.7.1",
"style-loader": "^1.0.0",
"traverse": "^0.6.6",
"uglifyjs-webpack-plugin": "^1.0.0-beta.2",
"underscore": "^1.8.3",
"webpack": "^4",
"webpack-combine-loaders": "^2.0.4"
"webpack": "^5"
},
"devDependencies": {
"babel-cli": "^6.9.0",
"babel-core": "^6.9.0",
"babel-plugin-transform-class-properties": "^6.11.5",
"babel-plugin-transform-function-bind": "^6.8.0",
"babel-preset-es2015": "^6.9.0",
"@babel/cli": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.21.0",
"bluebird": "^3.0.6",
"chai": "^3.4.1",
"chai-as-promised": "^5.1.0",
"documentation": "^4.0.0-beta9",
"documentation": "^13.2.5",
"mocha": "^3.2.0",
"should": "^7.0.2",
"sinon": "^1.17.2"
Expand Down
Loading