liferay / liferay-amd-loader

GNU Lesser General Public License v3.0
18 stars 20 forks source link

AMD Loader Testing in liferay #234

Closed Aravinth2307 closed 4 years ago

Aravinth2307 commented 4 years ago

Hi, I m not able to use the custom amd module defined in node_modules folder. I am getting below error. liferay-amd-loader | A require() call has failed but no failure handler was provided.

Step 1: I created a javascript widget using npm. Step 2: Create one folder named constants in node_modules folder. index.js

var constant-custom = define('constant-custom', {one: 1, two: 2});
module.exports = constant-custom;

package.json

{
  "name": "constant-custom@^1.0.0",
  "version": "1.0.0",
  "main": "index.js"
}

Step 4: In main package.json added this dependency

 "dependencies": {
    "constant-custom":"^1.0.0"
  }

Step 5: In my code I m using


try {
                require(
                    "constants", 
                    function(constants) {
                        console.log('constants', constants);
                    }
                );
            } catch(err) {
                console.log(err);
            }

```Could you please guide me if I m missing anything.
izaera commented 4 years ago

I think you should start here :point_right: https://github.com/liferay/liferay-js-toolkit/wiki

The AMD loader is a low level feature that shouldn't be used directly. Better rely on the JS Toolkit to build your JS portlets.

Aravinth2307 commented 4 years ago

Hi Zera, Thanks for your reply. I followed below link to create the amd javascript widget module. https://github.com/liferay/liferay-js-toolkit/wiki/How-to-use-generator-liferay-js Still I face the issue. Could you please guide me on this. Thanks in Advance.

izaera commented 4 years ago

Hi @Aravinth2307:

For that kind of things it is better to use Liferay Forums (https://liferay.dev/forums) or the Liferay Community Slack (https://liferay-community.slack.com/). This project's issues section is only intended for bug fixing and feature requests.

Cheers, Ivan