pax_global_header00006660000000000000000000000064127330515430014515gustar00rootroot0000000000000052 comment=f2dc8f7d2ad0c9af1d431c9acfc86dcd95f6e363 rollup-plugin-string-2.0.2/000077500000000000000000000000001273305154300156335ustar00rootroot00000000000000rollup-plugin-string-2.0.2/.gitignore000066400000000000000000000000221273305154300176150ustar00rootroot00000000000000node_modules dist rollup-plugin-string-2.0.2/.travis.yml000066400000000000000000000000761273305154300177470ustar00rootroot00000000000000language: node_js node_js: - '0.12' - '4' - '5' - '6' rollup-plugin-string-2.0.2/CHANGELOG.md000066400000000000000000000004141273305154300174430ustar00rootroot00000000000000# 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 rollup-plugin-string-2.0.2/LICENSE000066400000000000000000000020621273305154300166400ustar00rootroot00000000000000Copyright (c) Bogdan Chadkin 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. rollup-plugin-string-2.0.2/README.md000066400000000000000000000012331273305154300171110ustar00rootroot00000000000000# 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@yandex.ru) rollup-plugin-string-2.0.2/index.js000066400000000000000000000006501273305154300173010ustar00rootroot00000000000000import { 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: '' } }; } } }; } rollup-plugin-string-2.0.2/package.json000066400000000000000000000017731273305154300201310ustar00rootroot00000000000000{ "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 ", "license": "MIT", "bugs": { "url": "https://github.com/TrySound/rollup-plugin-string/issues" }, "homepage": "https://github.com/TrySound/rollup-plugin-string" } rollup-plugin-string-2.0.2/rollup.config.js000066400000000000000000000004021273305154300207460ustar00rootroot00000000000000import 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'] } ] }; rollup-plugin-string-2.0.2/test/000077500000000000000000000000001273305154300166125ustar00rootroot00000000000000rollup-plugin-string-2.0.2/test/fixtures/000077500000000000000000000000001273305154300204635ustar00rootroot00000000000000rollup-plugin-string-2.0.2/test/fixtures/basic.js000066400000000000000000000002471273305154300221050ustar00rootroot00000000000000import tpl from './templates/tpl.html'; assert.equal(typeof tpl, 'string'); assert.notEqual(tpl.indexOf('section'), -1); assert.notEqual(tpl.indexOf('article'), -1); rollup-plugin-string-2.0.2/test/fixtures/templates/000077500000000000000000000000001273305154300224615ustar00rootroot00000000000000rollup-plugin-string-2.0.2/test/fixtures/templates/tpl.html000066400000000000000000000002011273305154300241370ustar00rootroot00000000000000
Article 1
Article 2
rollup-plugin-string-2.0.2/test/index.js000066400000000000000000000017321273305154300202620ustar00rootroot00000000000000var 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/); }); });