AMD NetSuite instructions incorrect #3057

Closed
opened 2024-01-17 19:00:58 +00:00 by ben-ekw · 5 comments

Great project!

FYI, I believe your AMD NetSuite instructions are incorrect. On https://docs.sheetjs.com/docs/getting-started/installation/amd your instructions are:

define(['N/file', './xlsx.full.min'], function(file, XLSX) {
  // ... use XLSX here
})

That's not working for me. It says "module aliases can be created in config files" but they appear to be required.

For example, not working:

/**
 * @NApiVersion 2.x
 * @NScriptType Suitelet
 */
define(["./xlsx.full.min"], function (XLSX) {
  function onRequest(context) {
    context.response.write(typeof XLSX); // undefined
  }
  return { onRequest: onRequest };
});

Working:

JsLibraryConfig.json

{
  "paths": {
    "xlsx": "./xlsx.full.min"
  }
}
/**
 * @NApiVersion 2.x
 * @NAmdConfig ./JsLibraryConfig.json
 * @NScriptType Suitelet
 */
define(["xlsx"], function (XLSX) {
  function onRequest(context) {
    context.response.write(typeof XLSX); // object
  }
  return { onRequest: onRequest };
});
Great project! FYI, I believe your AMD NetSuite instructions are incorrect. On https://docs.sheetjs.com/docs/getting-started/installation/amd your instructions are: ``` define(['N/file', './xlsx.full.min'], function(file, XLSX) { // ... use XLSX here }) ``` That's not working for me. It says "module aliases can be created in config files" but they appear to be required. For example, **not working**: ``` /** * @NApiVersion 2.x * @NScriptType Suitelet */ define(["./xlsx.full.min"], function (XLSX) { function onRequest(context) { context.response.write(typeof XLSX); // undefined } return { onRequest: onRequest }; }); ``` **Working**: _JsLibraryConfig.json_ ``` { "paths": { "xlsx": "./xlsx.full.min" } } ``` ``` /** * @NApiVersion 2.x * @NAmdConfig ./JsLibraryConfig.json * @NScriptType Suitelet */ define(["xlsx"], function (XLSX) { function onRequest(context) { context.response.write(typeof XLSX); // object } return { onRequest: onRequest }; }); ```
Owner

The instructions for NAmdConfig are in https://docs.sheetjs.com/docs/demos/cloud/netsuite#installation (linked from the AMD page in the following paragraph)

Supposedly the direct method works (see the counter.js example in https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4704111062.html#bridgehead_4709270634 ). We don't have direct access to a NetSuite developer account -- the guides were written based on support requests and conversations with SheetJS Pro customers who are deploying in NetSuite.

Out of curiosity, does it work if you add the .js extension?

define(['N/file', './xlsx.full.min.js'], function(file, XLSX) {
  --------------------------------^^^
The instructions for `NAmdConfig` are in https://docs.sheetjs.com/docs/demos/cloud/netsuite#installation (linked from the AMD page in the following paragraph) Supposedly the direct method works (see the `counter.js` example in https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4704111062.html#bridgehead_4709270634 ). We don't have direct access to a NetSuite developer account -- the guides were written based on support requests and conversations with SheetJS Pro customers who are deploying in NetSuite. Out of curiosity, does it work if you add the `.js` extension? ```js define(['N/file', './xlsx.full.min.js'], function(file, XLSX) { --------------------------------^^^ ```
Author

Good idea, but no, doesn't work

Good idea, but no, doesn't work
Author

I'll use the NAmdConfig method, just thought you might want to update that other page in case it caused others confusion. :)

I'll use the `NAmdConfig` method, just thought you might want to update that other page in case it caused others confusion. :)
Author

P.S. You may want to use the UMD format, which supports AMD, CommonJS, Node.JS, and others: https://gist.github.com/ben-ekw/82a117294ece4b55b49766be31927018

P.S. You may want to use the UMD format, which supports AMD, CommonJS, Node.JS, and others: https://gist.github.com/ben-ekw/82a117294ece4b55b49766be31927018
Owner

Thanks for the feedback! The direct script approach has been removed from the docs. The page now includes specific instructions for the module alias approach.

Thanks for the feedback! The direct script approach has been removed from the docs. The page now includes specific instructions for the module alias approach.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#3057
No description provided.