<@U8CT0V220> I had more of a problem with netsuite...
# suitescript
f
@jkabot I had more of a problem with netsuite claiming that I don't have a
pageInit
method exported. Because my code was
const Obj = { pageInit: function() {} }; return Obj;
but it needs
return { pageInit: function() {} };
j
that's interesting. I'm guessing that's how webpack translated the es6 exports to AMD?
f
Yep correctly. So I had to workaround tell Webpack to export everything into a variable and use a custom plugin that wraps the variable into netsuite AMD syntax and manual export
pageInit
at the bottom so that Netsuite lets me upload my code
Its working so I am not complaining. Just took a bit of trial and error
j
😵 I've had my own experiences battling the static analyzer but that's pretty crazy I've used the typescript and babel compilers without webpack and they do it like this
Copy code
export function pageInit() {}
becomes
Copy code
define(["exports"], function(exports) {
  function pageInit() {}
  exports.pageInit = pageInit;
});
f
haha and I assume Netsuite does not like it?
j
No it works fine actually simple smile
f
I am surprised. Netsuite is sometimes weird. Anyways I am super excited that we got internal approval for using React in our project and can't wait to have the page rebuild with react components to be able to mask away poor Netsuite performance with a modern and responsive UI 😄
j
An example of a problem I've seen is where the compilers wrap imported modules using an interoperability function and the static analyzer sees that thinks you are trying to use a NetSuite API outside of an "entry" point i.e. it thinks you are trying to do something like this
Copy code
define(["N/record"], function(record) {
  // outside of an entry point like beforeLoad / pageInit etc
  var rec = record.load({ type: ... , id: ... })
})
Yeah, my experience with the task status react component has convinced me that it works pretty well since you can pretty much entirely encapsulate the React UI within an inlinehtml field and a dynamically imported client script
f
Btw is there an easy way to upload CSS files etc and put them in your bundle and load them dynamically? Currently I am considering just using webpack to inline css my styles
j
From my research the only way to do have your css be applied by import them into the jsx / tsx file like
import ./style.css
is using webpack
f
yeah thats what I thought
j
I didn't use webpack, so I ended up putting a
<style>
element within the inlinehtml field that also has my
<div id="react-root">