Estoy trabajando en un proyecto antiguo en el trabajo y parece estar usando rollup.js para agrupar.
Me gustaría usar el complemento sanitize-html para cambiar algunas entradas, pero aparece el error de que el valor predeterminado no se exporta:
[ERROR] Error: 'default' is not exported by src/path/node_modules/sanitize-html/index.js, imported by src/path/src/iql-editor/iql-editor.js [ERROR] at error (path/node_modules/rollup/dist/shared/rollup.js:158:30) [ERROR] at Module.error (path/node_modules/rollup/dist/shared/rollup.js:12382:16) [ERROR] at Module.traceVariable (path/node_modules/rollup/dist/shared/rollup.js:12767:29) [ERROR] at ModuleScope.findVariable (path/node_modules/rollup/dist/shared/rollup.js:11559:39) [ERROR] at ReturnValueScope.findVariable (path/node_modules/rollup/dist/shared/rollup.js:6930:38)Probé un par de cosas, primero agregué la dependencia en el paquete local.json:
"dependencies": { "popper.js": "^1.14.3", "sanitize-html": "^2.3.3" }, Y actualicé el archivo rollup.config.js así:
const path = require('path'); import { babel } from '@rollup/plugin-babel'; import { nodeResolve } from '@rollup/plugin-node-resolve'; const BUNDLE = process.env.BUNDLE === 'true'; const FORMAT = process.env.FORMAT || 'iife'; const destDirectory = '../dist/js/'; let destFile = %path%; const external = ['popper.js', 'sanitize-html']; const plugins = [ babel({ exclude: 'node_modules/**', // only transpile our source code }), ]; const globals = { 'popper.js': 'Popper', 'sanitize-html': 'sanitizeHtml', }; if (BUNDLE) { destFile = %path%; // remove last entry in external array to bundle Popper external.pop(); delete globals['popper.js']; delete globals['sanitize-html']; plugins.push(nodeResolve()); } module.exports = { input: path.resolve(__dirname, '../%path%'), output: { file: path.resolve(__dirname, `${destDirectory}${destFile}`), format: FORMAT, banner: `banner`, name: 'name', globals, }, external, plugins, };La extensión popper ya estaba presente, así que seguí la misma lógica.
En mi archivo de trabajo, estoy usando el complemento html-sanitize de esta manera:
import Popper from 'popper.js'; import sanitizeHtml from 'sanitize-html'; ... const anyName = (() => { this.doSomething( elt.value, sanitizeHtml(elt.displayValue), word, elt.type ) });¿Qué estoy haciendo mal?