<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Liferay Frontend - npm builder : how to share JS ?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112167593" />
  <subtitle>Liferay Frontend - npm builder : how to share JS ?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112167593</id>
  <updated>2026-04-04T21:48:46Z</updated>
  <dc:date>2026-04-04T21:48:46Z</dc:date>
  <entry>
    <title>RE: Liferay Frontend - npm builder : how to share JS ?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112173391" />
    <author>
      <name>Iván Zaera Avellón</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112173391</id>
    <updated>2019-01-30T07:57:18Z</updated>
    <published>2019-01-30T07:57:18Z</published>
    <summary type="html">Hi Eric:&lt;br /&gt;&lt;br /&gt;As you have guessed, the proper require syntax is &amp;#34;splunk-shared$splunk-sdk@1.8.4&amp;#34;. That is because your shared bundle is called &amp;#34;splunk-shared&amp;#34; and that namespaces &amp;#34;splunk-sdk&amp;#34; with the &amp;#34;splunk-shared$&amp;#34; prefix. You can find more about namespacing here:&lt;br /&gt;&lt;br /&gt;&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;&lt;a href="https://github.com/liferay/liferay-npm-build-tools/wiki/Miscellaneous-resources#blog-posts"&gt;https://github.com/liferay/liferay-npm-build-tools/wiki/Miscellaneous-resources#blog-posts&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="https://github.com/liferay/liferay-npm-build-tools/wiki/How-Liferay-serves-npm-packages-to-the-browser#per-project-package-isolation-new-since-liferay-npm-bundler-2"&gt;https://github.com/liferay/liferay-npm-build-tools/wiki/How-Liferay-serves-npm-packages-to-the-browser#per-project-package-isolation-new-since-liferay-npm-bundler-2&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Regarding the source map, it is not commented, that&amp;#39;s the standard syntax:&lt;br /&gt;&lt;br /&gt;&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;&lt;a href="https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/"&gt;https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;And, to finish with, the &amp;#34;The provided configuration is not Directed Acyclic Graph&amp;#34; message means that you have circular dependencies in your setup which is a bad thing because we don&amp;#39;t support it yet :-(. There are some workarounds with webpack and an issue to centralize all the information regarding that feature:&lt;br /&gt;&lt;br /&gt;&lt;ul style="list-style: disc outside;"&gt;&lt;li&gt;&lt;a href="https://github.com/liferay/liferay-amd-loader/issues/182"&gt;https://github.com/liferay/liferay-amd-loader/issues/182&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Hope this helps.</summary>
    <dc:creator>Iván Zaera Avellón</dc:creator>
    <dc:date>2019-01-30T07:57:18Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay Frontend - npm builder : how to share JS ?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112168270" />
    <author>
      <name>Eric COQUELIN</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112168270</id>
    <updated>2019-01-29T22:07:26Z</updated>
    <published>2019-01-29T22:07:26Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;The last but probably not the very last, when using&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;aui:script require="splunk-shared$splunk-sdk@1.8.4"&amp;gt;
console.log("splunkjs=" +splunkjs);
&amp;lt;/aui:script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;It looks it goes in the right direction but my browser shows the following messages&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;Error: "Error processing module: splunk-shared$readable-stream@2.0.6/lib/_stream_duplex. The provided configuration is not Directed Acyclic Graph."&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;AND the same as before&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;Erreur dans les liens source : request failed with status 404 URL de la ressource : http://localhost:8080/combo?browserId=firefox&amp;amp;amp;minifierType=js&amp;amp;amp;languageId=en_US&amp;amp;amp;b=7101&amp;amp;amp;t=1548795097782&amp;amp;amp;/o/frontend-js-web/jquery/jquery.js&amp;amp;amp;/o/frontend-js-web/clay/popper.js&amp;amp;amp;/o/frontend-js-web/clay/bootstrap.js&amp;amp;amp;/o/frontend-js-web/loader/config.js&amp;amp;amp;/o/frontend-js-web/loader/loader.js&amp;amp;amp;/o/frontend-js-web/lodash/lodash.js&amp;amp;amp;/o/frontend-js-web/aui/aui/aui.js&amp;amp;amp;/o/frontend-js-web/aui/aui-base-html5-shiv/aui-base-html5-shiv.js&amp;amp;amp;/o/frontend-js-web/liferay/browser_selectors.js&amp;amp;amp;/o/frontend-js-web/liferay/modules.js&amp;amp;amp;/o/frontend-js-web/liferay/aui_sandbox.js&amp;amp;amp;/o/frontend-js-web/clay/collapsible-search.js&amp;amp;amp;/o/frontend-js-web/clay/side-navigation.js&amp;amp;amp;/o/frontend-js-web/jquery/fm.js&amp;amp;amp;/o/frontend-js-web/jquery/form.js&amp;amp;amp;/o/frontend-js-web/lodash/util.js&amp;amp;amp;/o/frontend-js-web/misc/svg4everybody.js&amp;amp;amp;/o/frontend-js-web/aui/arraylist-add/arraylist-add.js&amp;amp;amp;/o/frontend-js-web/aui/arraylist-filter/arraylist-filter.js&amp;amp;amp;/o/frontend-js-web/aui/arraylist/arraylist.js&amp;amp;amp;/o/frontend-js-web/aui/array-extras/array-extras.js&amp;amp;amp;/o/frontend-js-web/aui/array-invoke/array-invoke.js&amp;amp;amp;/o/frontend-js-web/aui/attribute-base/attribute-base.js&amp;amp;amp;/o/frontend-js-web/aui/attribute-complex/attribute-complex.js&amp;amp;amp;/o/frontend-js-web/aui/attribute-core/attribute-core.js&amp;amp;amp;/o/frontend-js-web/aui/attribute-observable/attribute-observable.js&amp;amp;amp;/o/frontend-js-web/aui/attribute-extras/attribute-extras.js&amp;amp;amp;/o/frontend-js-web/aui/base-base/base-base.js&amp;amp;amp;/o/frontend-js-web/aui/base-pluginhost/base-pluginhost.js&amp;amp;amp;/o/frontend-js-web/aui/classnamemanager/classnamemanager.js&amp;amp;amp;/o/frontend-js-web/aui/datatype-xml-format/datatype-xml-format.js&amp;amp;amp;/o/frontend-js-web/aui/datatype-xml-parse/datatype-xml-parse.js&amp;amp;amp;/o/frontend-js-web/aui/dom-base/dom-base.js&amp;amp;amp;/o/frontend-js-web/aui/dom-core/dom-core.js&amp;amp;amp;/o/frontend-js-web/aui/dom-screen/dom-screen.js&amp;amp;amp;/o/frontend-js-web/aui/dom-style/dom-style.js&amp;amp;amp;/o/frontend-js-web/aui/event-base/event-base.js&amp;amp;amp;/o/frontend-js-web/aui/event-custom-base/event-custom-base.js&amp;amp;amp;/o/frontend-js-web/aui/event-custom-complex/event-custom-complex.js&amp;amp;amp;/o/frontend-js-web/aui/event-delegate/event-delegate.js URL du lien source : loader.js.map&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Eric COQUELIN</dc:creator>
    <dc:date>2019-01-29T22:07:26Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay Frontend - npm builder : how to share JS ?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112167936" />
    <author>
      <name>Eric COQUELIN</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112167936</id>
    <updated>2019-01-29T21:57:35Z</updated>
    <published>2019-01-29T21:57:35Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I have been through another test using following syntax&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;aui:script require="splunk-shared@1.0.0"&amp;gt;

console.log("splunkjs=" +splunkjs);

&amp;lt;/aui:script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;I don't get anymore the problem saying that it doesn't know what splunk-shared is and have a bootstrap message I put in my index.js. But the console.log(...) is not displayed. I get the following error in the browser&lt;br&gt;&lt;pre&gt;&lt;code&gt;
Erreur dans les liens source : request failed with status 404 URL de la ressource : http://localhost:8080/combo/?browserId=firefox&amp;amp;amp;minifierType=&amp;amp;amp;languageId=en_US&amp;amp;amp;b=7101&amp;amp;amp;t=1548795097782&amp;amp;amp;/o/js/resolved-module/frontend-js-metal-web@2.0.4/bridge/metal-dom/src/all/dom.js&amp;amp;amp;/o/js/resolved-module/frontend-js-metal-web@2.0.4/bridge/metal-uri/src/Uri.js&amp;amp;amp;/o/js/resolved-module/frontend-js-metal-web$metal-position@2.1.1/lib/Geometry.js&amp;amp;amp;/o/js/resolved-module/frontend-js-metal-web$metal-position@2.1.1/lib/Position.js&amp;amp;amp;/o/js/resolved-module/frontend-js-metal-web$metal-position@2.1.1/lib/Align.js&amp;amp;amp;/o/js/resolved-module/frontend-js-metal-web$metal-position@2.1.1/lib/all/position.js&amp;amp;amp;/o/js/resolved-module/frontend-taglib-clay$clay-tooltip@2.3.4/lib/ClayTooltip.soy.js&amp;amp;amp;/o/js/resolved-module/frontend-taglib-clay$clay-tooltip@2.3.4/lib/ClayTooltip.js&amp;amp;amp;/o/js/resolved-module/frontend-taglib-clay@1.2.4/bridge/clay-tooltip/src/ClayTooltip.js&amp;amp;amp;/o/js/resolved-module/splunk-shared@1.0.0/index.js URL du lien source : index.js.map&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;It looks like it looks for the index.js.map but when I check the build/index.js (autogenerated from my index.js), I have&lt;br&gt;&lt;pre&gt;&lt;code&gt;Liferay.Loader.define("splunk-shared@1.0.0/index", ['module', 'exports', 'require'], function (module, exports, require) {
  var define = undefined;
  console.log("bootstrapped splunk-shared");
  //# sourceMappingURL=index.js.map
});
//# sourceMappingURL=index.js.map
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;So it looks the map file is commented.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Eric COQUELIN</dc:creator>
    <dc:date>2019-01-29T21:57:35Z</dc:date>
  </entry>
  <entry>
    <title>Liferay Frontend - npm builder : how to share JS ?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112167592" />
    <author>
      <name>Eric COQUELIN</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112167592</id>
    <updated>2019-01-29T21:36:02Z</updated>
    <published>2019-01-29T21:36:02Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Dear community,&lt;br&gt;&lt;br&gt;I wish I could integrate Liferay 7.1 GA2 with Splunk (http://www.splunk.com) using their SDK. Unfortunatelty, due to JS loader introduced since 7.0 and as the proposed JS from Splunk use AMD loader, it brings some conflicts.&amp;nbsp; I need to package the splunk JS to use it properly in my portlets.&lt;br&gt;&lt;br&gt;I have been following different tutorial but spent more time on the one share during the last devcon about Angular.&lt;br&gt;&lt;br&gt;I initialized my liferay-npm-builder and added splunk-sdk as a dependency. As a result, I have:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;ecoquelin@kenitra:~/workspaces/splunk/splunk/modules/splunk-shared$ ll
total 300
drwxr-xr-x   8 ecoquelin ecoquelin   4096 janv. 29 22:20 ./
drwxr-xr-x   7 ecoquelin ecoquelin   4096 janv. 29 21:18 ../
drwxr-xr-x   2 ecoquelin ecoquelin   4096 janv. 29 21:18 assets/
-rw-r--r--   1 ecoquelin ecoquelin     24 janv. 29 21:18 .babelrc
drwxr-xr-x   3 ecoquelin ecoquelin   4096 janv. 29 22:05 build/
drwxr-xr-x   2 ecoquelin ecoquelin   4096 janv. 29 21:27 dist/
drwxr-xr-x   3 ecoquelin ecoquelin   4096 janv. 29 21:18 features/
-rw-r--r--   1 ecoquelin ecoquelin     61 janv. 29 21:18 .gitignore
-rw-r--r--   1 ecoquelin ecoquelin  58112 janv. 29 22:20 liferay-npm-bundler-report.html
drwxr-xr-x 381 ecoquelin ecoquelin  20480 janv. 29 21:19 node_modules/
-rw-r--r--   1 ecoquelin ecoquelin     73 janv. 29 21:18 .npmbuildrc
-rw-r--r--   1 ecoquelin ecoquelin    230 janv. 29 22:20 .npmbundlerrc
-rw-r--r--   1 ecoquelin ecoquelin    502 janv. 29 21:19 package.json
-rw-r--r--   1 ecoquelin ecoquelin 169408 janv. 29 21:19 package-lock.json
-rw-r--r--   1 ecoquelin ecoquelin     30 janv. 29 21:18 README.md
drwxr-xr-x   2 ecoquelin ecoquelin   4096 janv. 29 21:21 src/&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;My package.json&lt;br&gt;&lt;pre&gt;&lt;code&gt;{
    "name": "splunk-shared",
    "version": "1.0.0",
    "description": "Splunk Shared",
    "devDependencies": {
        "liferay-npm-bundler": "^2.6.1",
        "liferay-npm-build-support": "^2.6.1",
        "babel-cli": "^6.26.0",
        "babel-preset-env": "^1.7.0"
    },
    "dependencies": {
        "splunk-sdk": "^1.8.4"
    },
    "scripts": {
        "build": "babel --source-maps -d build src &amp;amp;amp;&amp;amp;amp; npm run copy-assets &amp;amp;amp;&amp;amp;amp; liferay-npm-bundler",
        "copy-assets": "lnbs-copy-assets",
        "deploy": "npm run build &amp;amp;amp;&amp;amp;amp; lnbs-deploy"
    },
    "main": "index.js"
}&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;my .npmbundlerrc&lt;br&gt;&lt;pre&gt;&lt;code&gt;{
    "create-jar": {
        "output-dir": "dist",
        "features": {
            "js-extender": false,
            "web-context": "/splunk-shared",
            "localization": "features/localization/Language"
        }
    },
    "dump-report": true,
    "process-serially": true

}&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;The above configuration is provided by default using &lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;yo liferay-bundle&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;And I selected "shared packages bundle"&lt;br&gt;&lt;br&gt;Now, I deploy successfully this package to Liferay&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;npm run deploy&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;And it looks like the OSGI module starts properly but I haven't found any way to check if my JS bundle is available somewhere...&lt;br&gt;&lt;br&gt;Then, from another portlet, I try to refer to this new bundle in a JSP page&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;aui:script require="splunk-shared"&amp;gt;

/* Liferay.Loader.require('splunk-shared', function(splunkjs) {
    console.log(splunkjs);
}, function(error) {
    console.error(error);
});
 */
&amp;lt;/aui:script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;As you may notice, I try both ways and in any cases it says that this bundle doesn't exist. I don't know which syntax to follow and don't know where to find the list of bundles available.&lt;br&gt;&lt;br&gt;I want to point to the splunk.js file available in the splunk-shared module folder&lt;br&gt;&lt;pre&gt;&lt;code&gt;modules/splunk-shared/node_modules/splunk-sdk/client/splunk.js&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;How should I proceed ?&lt;br&gt;&lt;br&gt;Thank you in advance for your help,&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Eric COQUELIN</dc:creator>
    <dc:date>2019-01-29T21:36:02Z</dc:date>
  </entry>
</feed>
