P
P
P_Alexander2019-10-09 16:05:44
JavaScript
P_Alexander, 2019-10-09 16:05:44

How to connect two requaers to a page so that they don't conflict!?

Good afternoon, according to the documentation, there can only be one entry point per page

<script data-main="scripts/main" src="scripts/requireJS.js"></script>

I need to take into account the situation that a requier can already be used, and here I also insert my requier, what should I do in this case?
I read about using context in the config file, but either I didn't understand how to use it or it's not very suitable for my situation!
I am now trying to implement it, but so far it turns out that the second call of the requester overwrites the first one and, accordingly, errors fly, here is an example:
<script type="text/javascript" src="scripts/requireJS.js"></script>
  <script type="text/javascript" src="scripts/main.js"></script>

var reqOne = requirejs.config({
  contex: 'v1',
  baseUrl: 'lib',
  paths: {'v': 'version1'},
  waitSeconds: 5
});
reqOne(['require','v'], (require, ver) => {
  	console.log( 'VERSION 1  is ', ver.version);
});

var reqTwo = requirejs.config({
  contex: 'v2',
  baseUrl: 'lib2',
  paths: { 'vTwo': 'version2' }
});

reqTwo(['require', 'vTwo'], (require, v) => {
  	console.log('VERSION 2 is ', ver.version)
});

Prompt, direct... Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
P_Alexander, 2019-10-10
@P_Alexander

I connected it, I just wrote the parameter in the requester config "contex" instead of "context" correctly :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question