I use PapaParse to load a csv file from file input.
I currently have a working version where I load PapaParse using the script tag:
<script type="text/javascript" src="papaparse.js" ></script>
And handle the change event:
Papa.parse(event.target.files[0], {
complete: function(results) {
...
}
}
Now I want to use webpack to combine my js, and I want to dynamically load PapaParse when I need it, and not every time in the global namespace. Something like that:
require("./papaparse.js").Papa.parse(event.target.files[0], {
complete: function(results) {
...
}
}
Unfortunately, this gives me an error Uncaught ReferenceError: Papa is not definedfrom this line in the PapaParse library:
if (!config.chunkSize)
config.chunkSize = Papa.LocalChunkSize;
Is there any way to make this work?
[change]
requirejs/webpack, , , ( , Windows), :
require("imports?this=>window!exports?global.Papa!./papaparse.js").parse(event.target.files[0], {
complete: function(results) {
...
}
}
, (imports?this=>window) global ( ). PapaParse global.document global.postMessage() ( , , Papa), , global.Papa). (exports?global.Papa) , Papa .
, -, webpack, , ?