Closed alokekantal closed 2 years ago
https://github.com/SheetJS/sheetjs/tree/master/demos/rollup#required-plugins mentions some override:
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
export default {
/* ... */
plugins: [
resolve({
module: false, // <-- this library is not an ES6 module
browser: true, // <-- suppress node-specific features
}),
commonjs()
],
/* ... */
};
Does that help?
Is this is separate config file?
Getting same issue. I added the above plugins in stencil.config.ts file.
Hello guys:
I'm using Ubuntu 20.04, and I'm having the same issue. Any solution available yet?
Thanks!
If there is an operating system problem, the issue almost lies with with the tooling. In this case, you should raise an issue in the StencilJS bug tracker. For example, https://github.com/ionic-team/stencil/issues/2610 is a similar case where something worked in Windows but not in Ubuntu.
But to be sure it isn't a SheetJS issue, a test was run on OSX Catalina 10.15.7 using npm init stencil
to create an "app". src/components/app-home/app-home.tsx
was changed to import and use the library:
import { Component, h } from '@stencil/core';
import { read } from 'xlsx';
const data = read("abc,def\nghi,jkl", {type: "string"}).Sheets.Sheet1.A1.v
@Component({
tag: 'app-home',
styleUrl: 'app-home.css',
shadow: true,
})
export class AppHome {
render() {
return (
<div class="app-home">
<p>
{data}
</p>
</div>
);
}
}
There is no rollup message in the hot reload (npm start
) and no warning in the build step (npm run build
)
The issue exists when rollup-plugin-node-polyfills is added to stencil.conf.js. Simple fix is to call nodePolyfills with additional options parameter and exclude sheetjs, e.g. stencil.conf.js:
{
...
rollupPlugins: {
after: [nodePolyfills({exclude: ["node_modules/xlsx/**"]})]
}
...
}
Thanks @MarkChrisLevy , the issue can be reproduced using that plugin and your solution works. Unfortunately that option is not in the plugin docs :(
The raw rollup demo works with the polyfills plugin, probably because it also uses rollup-plugin-node-resolve
(now @rollup/plugin-node-resolve
)
NOTE: if you are using stencil with
rollup-plugin-node-polyfills
, pass anexclude
optionI got the bellow error when I use xlsx module with stenciljs with MAC machine. Module is working fine in windows. Rollup: Missing Export: ./node_modules/xlsx/dist/cpexcel.js:1:9
'Buffer' is not exported by node-resolve:empty.js, imported by
./node_modules/xlsx/dist/cpexcel.js
L1: /! cpexcel.js (C) 2013-present SheetJS -- http://sheetjs.com /
L2: /jshint -W100 /
Thanks in advance