-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js.map
1 lines (1 loc) · 7.91 KB
/
index.js.map
1
{"version":3,"file":"index.js","sources":["src/make-filter.js","src/parse-options.js","src/proc-file.js","src/index.js"],"sourcesContent":["import { createFilter } from 'rollup-pluginutils'\nimport { extname } from 'path'\n\n/**\n * Creates a filter for the options `include`, `exclude`, and `extensions`.\n *\n * Since `extensions` is not a rollup option, I think is widely used.\n *\n * @param {import('..').Options} opts The user options\n * @param {string|string[]} exts Default extensions\n * @returns {function} Filter function that returns true if a given file\n * matches the filter.\n */\nconst makeFilter = (opts, exts) => {\n const _filt = createFilter(opts.include, opts.exclude)\n\n exts = opts.extensions || exts\n if (!exts || exts === '*') {\n return _filt // do not filter extensions\n }\n\n if (!Array.isArray(exts)) {\n exts = [exts]\n }\n exts = exts.map(e => (e[0] !== '.' ? `.${e}` : e))\n\n return id => _filt(id) && exts.includes(extname(id))\n}\n\nexport default makeFilter\n","import getPackageVersion from '@jsbits/get-package-version'\n\n/**\n * @param {import('..').Options} options -\n * @returns {import('jscc').Options}\n */\nconst parseOptions = options => {\n options = Object.assign(\n {\n prefixes: [/\\/[/*] ?/, /<!-- ?/],\n },\n options\n )\n\n options.values = Object.assign(\n {\n _VERSION: getPackageVersion(),\n },\n options.values\n )\n\n options.sourceMap = options.sourcemap !== false && options.sourceMap !== false\n\n return options\n}\n\nexport default parseOptions\n","import fs from 'fs'\nimport jscc from 'jscc'\n\n/**\n * Returns a shallow copy of the jscc options.\n *\n * @param {jscc.Options} opts\n * @returns {jscc.Options}\n */\nconst _getJsccOpts = opts => ({\n escapeQuotes: opts.escapeQuotes,\n keepLines: opts.keepLines,\n mapHires: opts.mapHires,\n prefixes: opts.prefixes,\n sourceMap: opts.sourceMap,\n mapContent: opts.mapContent !== false,\n values: Object.assign({}, opts.values),\n})\n\n/**\n * Simple wrapper for the async `fs.readFile` that returns a Promise that\n * resolves to a string with the content decoded as utf8.\n *\n * @param {string} fname Absolute or relative to cwd\n * @returns {Promise<string>}\n */\nconst _getSource = fname =>\n new Promise((resolve, reject) => {\n fs.readFile(fname, 'utf8', (error, data) => {\n // istanbul ignore if\n if (error) {\n reject(error)\n } else {\n resolve(data)\n }\n })\n })\n\n/**\n * Call jscc and returns a Promise that is resolved with a {code,map} object\n * or a string if the buffer did not change or `options.sourceMap:false`.\n *\n * @param {string} fname Absolute or relative to cwd\n * @param {jscc.Options} options jscc options\n * @param {string} [code] Source\n * @returns {Promise<string>}\n */\nconst procFile = (fname, options, code) => {\n // Supports transform\n const promise = code != null ? Promise.resolve(code) : _getSource(fname)\n\n return promise\n .then(source => {\n // Supports buffer\n if (typeof Buffer !== 'undefined' && Buffer.isBuffer(source)) {\n source = source.toString()\n }\n // Ignore non-string sources\n return typeof source === 'string'\n ? jscc(source, fname, _getJsccOpts(options))\n : source\n })\n .then(ret => {\n /*\n change the relative source path in the source map to the input file path\n explanation:\n rollup will resolve source path through the file's directory absolute path\n and the source path in the returned source map by the plugin\n\n new Source(resolve(dirname(module.id), originalSourcemap.sourceRoot || '.', source), sourcesContent[i])\n\n @see https://github.com/rollup/rollup/blob/v1.15.6/src/utils/collapseSourcemaps.ts#L196\n */\n if (ret.map) {\n ret.map.sources[0] = fname\n }\n return ret\n })\n}\n\nexport default procFile\n","import makeFilter from './make-filter'\nimport parseOptions from './parse-options'\nimport procFile from './proc-file'\n\nconst DEFAULT_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.tag']\n\n/**\n * rollup-plugin-jscc entry point\n *\n * @param {import('..').Options} options User options\n * @returns {import('rollup').Plugin}\n */\nexport default function jsccPlugin (options) {\n // Get the jscc options from the plugin options\n options = parseOptions(options)\n\n const filter = makeFilter(options, DEFAULT_EXTENSIONS)\n\n if (options.asloader !== false) {\n return {\n name: 'jscc',\n load: id => (filter(id) ? procFile(id, options) : null),\n }\n }\n\n return {\n name: 'jscc',\n transform: (code, id) => (filter(id) ? procFile(id, options, code) : null),\n }\n}\n"],"names":["createFilter","ext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