UNPKG

5.64 kBSource Map (JSON)View Raw
1{"version":3,"file":"index.js","sources":["../dist-src/index.js"],"sourcesContent":["import rollupCommonJs from 'rollup-plugin-commonjs';\nimport rollupJson from 'rollup-plugin-json';\nimport rollupNodeResolve from 'rollup-plugin-node-resolve';\nimport { terser as rollupTerser } from 'rollup-plugin-terser';\nimport rollupBabel from 'rollup-plugin-babel';\nimport babelPluginDynamicImportSyntax from '@babel/plugin-syntax-dynamic-import';\nimport babelPluginImportMetaSyntax from '@babel/plugin-syntax-import-meta';\nimport babelPresetEnv from '@babel/preset-env';\nimport path from 'path';\nimport fs from 'fs';\nimport { MessageError } from '@pika/types';\nimport { rollup } from 'rollup';\nexport async function beforeJob({ out }) {\n const srcDirectory = path.join(out, 'dist-web/');\n if (!fs.existsSync(srcDirectory)) {\n throw new MessageError('\"dist-web/\" does not exist. \"plugin-bundle-web\" requires \"plugin-build-dev\" to precede in pipeline.');\n }\n const srcEntrypoint = path.join(out, 'dist-web/index.js');\n if (!fs.existsSync(srcEntrypoint)) {\n throw new MessageError('\"dist-web/index.js\" is the expected standard entrypoint, but it does not exist.');\n }\n}\nexport function manifest(manifest, { options }) {\n if (options.entrypoint) {\n manifest[options.entrypoint] = 'dist-web/index.bundled.js';\n }\n}\nexport async function build({ out, options, reporter }) {\n const readFromWeb = path.join(out, 'dist-web', 'index.js');\n const writeToWeb = path.join(out, 'dist-web');\n const writeToWebBundled = path.join(writeToWeb, 'index.bundled.js');\n const result = await rollup({\n input: readFromWeb,\n plugins: [\n rollupNodeResolve({\n preferBuiltins: true,\n browser: !!options.browser,\n }),\n rollupCommonJs({\n include: 'node_modules/**',\n sourceMap: false,\n namedExports: options.namedExports,\n }),\n rollupJson({\n include: 'node_modules/**',\n compact: true,\n }),\n rollupBabel({\n babelrc: false,\n compact: false,\n presets: [\n [\n babelPresetEnv,\n {\n modules: false,\n targets: options.targets || { esmodules: true },\n },\n ],\n ],\n plugins: [babelPluginDynamicImportSyntax, babelPluginImportMetaSyntax],\n }),\n options.minify !== false\n ? rollupTerser(typeof options.minify === 'object'\n ? options.minify\n : undefined)\n : undefined,\n ],\n });\n await result.write({\n dir: writeToWeb,\n entryFileNames: '[name].bundled.js',\n chunkFileNames: '[name]-[hash].bundled.js',\n format: 'esm',\n exports: 'named',\n sourcemap: options.sourcemap === undefined ? true : options.sourcemap,\n });\n reporter.created(writeToWebBundled);\n}\n"],"names":["beforeJob","out","srcDirectory","path","join","fs","existsSync","MessageError","srcEntrypoint","manifest","options","entrypoint","build","reporter","readFromWeb","writeToWeb","writeToWebBundled","result","rollup","input","plugins","rollupNodeResolve","preferBuiltins","browser","rollupCommonJs","include","sourceMap","namedExports","rollupJson","compact","rollupBabel","babelrc","presets","babelPresetEnv","modules","targets","esmodules","babelPluginDynamicImportSyntax","babelPluginImportMetaSyntax","minify","rollupTerser","undefined","write","dir","entryFileNames","chunkFileNames","format","exports","sourcemap","created"],"mappings":";;;;;;;;;;;;;;;;;;;AAYO,eAAeA,SAAf,CAAyB;EAAEC;CAA3B,EAAkC;QAC/BC,YAAY,GAAGC,IAAI,CAACC,IAAL,CAAUH,GAAV,EAAe,WAAf,CAArB;;MACI,CAACI,EAAE,CAACC,UAAH,CAAcJ,YAAd,CAAL,EAAkC;UACxB,IAAIK,kBAAJ,CAAiB,qGAAjB,CAAN;;;QAEEC,aAAa,GAAGL,IAAI,CAACC,IAAL,CAAUH,GAAV,EAAe,mBAAf,CAAtB;;MACI,CAACI,EAAE,CAACC,UAAH,CAAcE,aAAd,CAAL,EAAmC;UACzB,IAAID,kBAAJ,CAAiB,iFAAjB,CAAN;;;AAGR,AAAO,SAASE,QAAT,CAAkBA,QAAlB,EAA4B;EAAEC;CAA9B,EAAyC;MACxCA,OAAO,CAACC,UAAZ,EAAwB;IACpBF,QAAQ,CAACC,OAAO,CAACC,UAAT,CAAR,GAA+B,2BAA/B;;;AAGR,AAAO,eAAeC,KAAf,CAAqB;EAAEX,GAAF;EAAOS,OAAP;EAAgBG;CAArC,EAAiD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