gitbrent / PptxGenJS

Create PowerPoint presentations with a powerful, concise JavaScript API.
https://gitbrent.github.io/PptxGenJS/
MIT License
2.88k stars 633 forks source link

[BUG] Cannot import in es6 with rollup, "stream" bare identifier #1219

Open phun-ky opened 1 year ago

phun-ky commented 1 year ago

Issue Category

Product Versions

Desired Behavior

That I am able to dynamically and normal import this app without errors in es6

Observed Behavior

With this:

const a = await import('pptxgenjs');
// or 
const a = await import('pptxgenjs/dist/pptxgen.es.js');
// or
import a from 'pptxgenjs';
// or
import a from 'pptxgenjs/dist/pptxgen.es.js';

I get:

Uncaught (in promise) TypeError: The specifier “stream” was a bare 
specifier, but was not remapped to anything. Relative module specifiers 
must start with “./”, “../” or “/”.

Steps to Reproduce

Use this rollup config:

rollup.config.js ``` import { nodeResolve } from '@rollup/plugin-node-resolve'; import json from '@rollup/plugin-json'; import styles from 'rollup-plugin-styles'; import { terser } from 'rollup-plugin-terser'; import svg from 'rollup-plugin-svg-import'; import commonjs from '@rollup/plugin-commonjs'; // import { generateImageSizes } from 'rollup-plugin-generate-image-sizes'; export default [ { input: ['src/dtm.js'], external: (id) => { if (id.includes('history')) return true; return false; }, output: { name: 'dtm', format: 'es', sourcemap: true, exports: 'named', dir: './dist', assetFileNames: '[name][extname]' }, plugins: [ nodeResolve({ preferBuiltins: true }), commonjs(), // generateImageSizes({ // dir: 'assets/images', // maxParallel: 1 // }), svg({ // process SVG to DOM Node or String. Default: false stringify: true }), styles({ mode: 'extract', url: false }), json(), terser() ] } ]; ```

And then this code:


const a = await import('pptxgenjs');
// or 
const a = await import('pptxgenjs/dist/pptxgen.es.js');
// or
import a from 'pptxgenjs';
// or
import a from 'pptxgenjs/dist/pptxgen.es.js';