[Pkg-javascript-commits] [node-rollup-plugin-string] 01/03: New upstream version 2.0.2
Julien Puydt
julien.puydt at laposte.net
Wed Jul 5 19:52:20 UTC 2017
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-rollup-plugin-string.
commit 3d6c191b237fc458963485c6068bbfa9f80aebb9
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Wed Jul 5 20:34:28 2017 +0200
New upstream version 2.0.2
---
.gitignore | 2 ++
.travis.yml | 6 ++++++
CHANGELOG.md | 22 +++++++++++++++++++++
LICENSE | 22 +++++++++++++++++++++
README.md | 38 +++++++++++++++++++++++++++++++++++++
index.js | 22 +++++++++++++++++++++
package.json | 41 ++++++++++++++++++++++++++++++++++++++++
rollup.config.js | 18 ++++++++++++++++++
test/fixtures/basic.js | 5 +++++
test/fixtures/templates/tpl.html | 4 ++++
test/index.js | 33 ++++++++++++++++++++++++++++++++
11 files changed, 213 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f06235c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+dist
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..5a60df6
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - '0.12'
+ - '4'
+ - '5'
+ - '6'
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..b269787
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,22 @@
+# Changelog
+
+## 2.0.2
+
+* Return a `name`
+
+## 2.0.1
+
+* Reverted transform return empty map
+
+## 2.0.0
+
+* Remove ext option in favour of include/exclude convention
+
+## 1.0.1
+
+* Use rollup cli and rollup.config.js
+* Generate only `cjs` format
+
+## 1.0.0
+
+* Initial release
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6dcaefc
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) Bogdan Chadkin <trysound at yandex.ru>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f593ca2
--- /dev/null
+++ b/README.md
@@ -0,0 +1,38 @@
+# rollup-plugin-string [![Build Status](https://travis-ci.org/TrySound/rollup-plugin-string.svg)](https://travis-ci.org/TrySound/rollup-plugin-string)
+
+Converts text files to modules:
+
+```js
+import tpl from './tpl.html';
+console.log( `Template for render: ${tpl}` );
+```
+
+## Installation
+
+```sh
+npm i rollup-plugin-string -D
+```
+
+## Usage
+
+```js
+import { rollup } from 'rollup';
+import string from 'rollup-plugin-string';
+
+rollup({
+ entry: 'main.js',
+ plugins: [
+ string({
+ // Required to be specified
+ include: '**/*.html',
+
+ // Undefined by default
+ exclude: ['**/index.html']
+ })
+ ]
+});
+```
+
+# License
+
+MIT © [Bogdan Chadkin](mailto:trysound at yandex.ru)
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..a903cee
--- /dev/null
+++ b/index.js
@@ -0,0 +1,22 @@
+import { createFilter } from 'rollup-pluginutils';
+
+export default function string(opts = {}) {
+ if (!opts.include) {
+ throw Error('include option should be specified');
+ }
+
+ const filter = createFilter(opts.include, opts.exclude);
+
+ return {
+ name: 'string',
+
+ transform(code, id) {
+ if (filter(id)) {
+ return {
+ code: `export default ${JSON.stringify(code)};`,
+ map: { mappings: '' }
+ };
+ }
+ }
+ };
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..6eed1f2
--- /dev/null
+++ b/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "rollup-plugin-string",
+ "version": "2.0.2",
+ "description": "Converts text files to modules",
+ "main": "dist/rollup-plugin-string.js",
+ "jsnext:main": "dist/rollup-plugin-string.mjs",
+ "files": [
+ "dist"
+ ],
+ "dependencies": {
+ "rollup-pluginutils": "^1.5.0"
+ },
+ "devDependencies": {
+ "buble": "^0.10.6",
+ "mocha": "^2.5.3",
+ "rollup": "^0.31.0",
+ "rollup-plugin-buble": "^0.10.0"
+ },
+ "scripts": {
+ "build": "rollup -c",
+ "pretest": "npm run build",
+ "test": "mocha test/*.js --compilers js:buble/register",
+ "prepublish": "npm test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/TrySound/rollup-plugin-string.git"
+ },
+ "keywords": [
+ "rollup-plugin",
+ "stringify",
+ "string",
+ "template"
+ ],
+ "author": "Bogdan Chadkin <trysound at yandex.ru>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/TrySound/rollup-plugin-string/issues"
+ },
+ "homepage": "https://github.com/TrySound/rollup-plugin-string"
+}
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 0000000..3a33706
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,18 @@
+import buble from 'rollup-plugin-buble';
+
+var pkg = require('./package.json');
+
+export default {
+ entry: 'index.js',
+ plugins: [buble()],
+ targets: [
+ {
+ format: 'cjs',
+ dest: pkg['main']
+ },
+ {
+ format: 'es6',
+ dest: pkg['jsnext:main']
+ }
+ ]
+};
diff --git a/test/fixtures/basic.js b/test/fixtures/basic.js
new file mode 100644
index 0000000..040377f
--- /dev/null
+++ b/test/fixtures/basic.js
@@ -0,0 +1,5 @@
+import tpl from './templates/tpl.html';
+
+assert.equal(typeof tpl, 'string');
+assert.notEqual(tpl.indexOf('section'), -1);
+assert.notEqual(tpl.indexOf('article'), -1);
diff --git a/test/fixtures/templates/tpl.html b/test/fixtures/templates/tpl.html
new file mode 100644
index 0000000..f901473
--- /dev/null
+++ b/test/fixtures/templates/tpl.html
@@ -0,0 +1,4 @@
+<section class="section">
+ <article class='article'>Article 1</article>
+ <article class='article'>Article 2</article>
+</section>
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000..1ab3353
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,33 @@
+var assert = require('assert');
+var { rollup } = require('rollup');
+var string = require('../');
+
+process.chdir('test');
+
+function makeBundle(options, stringOptions) {
+ options.plugins = [string(stringOptions)];
+ return rollup(options);
+}
+
+describe('rollup-plugin-string', () => {
+ it('should stringify importing template', () => {
+ return makeBundle({ entry: 'fixtures/basic.js' }, { include: '**/*.html' }).then(bundle => {
+ const { code } = bundle.generate({ format: 'iife', moduleName: 'tpl' });
+ new Function('assert', code)(assert);
+ });
+ });
+
+ it('should output empty sourcemap', () => {
+ return makeBundle({ entry: 'fixtures/basic.js' }, { include: '**/*.html' }).then(bundle => {
+ const { code, map } = bundle.generate({ sourceMap: true });
+ assert.ok(code);
+ assert.ok(map);
+ });
+ });
+
+ it('throws when include is not specified', () => {
+ assert.throws(() => {
+ makeBundle({ entry: 'fixtures/basic.js' });
+ }, /include option should be specified/);
+ });
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-rollup-plugin-string.git
More information about the Pkg-javascript-commits
mailing list