Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The result of import multiple amd module is uncertain #2111

Closed
FreezeSoul opened this issue Jan 29, 2020 · 8 comments
Closed

The result of import multiple amd module is uncertain #2111

FreezeSoul opened this issue Jan 29, 2020 · 8 comments

Comments

@FreezeSoul
Copy link

FreezeSoul commented Jan 29, 2020

When update to 6.1.10, i got a problem,but the 6.1.9 is ok.

I import more than one amd module,but the result is uncertain.

When i refresh the following page,the console output moudles: jquery,jquery,jquery,or other. Evertime is not same.

I want to get moudles : jquery,lodash,sockjs,stomp .

<!DOCTYPE html>
<html lang="en-US">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Basic Webpack SystemJS Example</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script type="systemjs-importmap">
    {
  	"imports": {
		"jquery": "./library/jquery/jquery.min.js",
		"lodash": "./library/lodash/lodash.min.js",
		"sockjs": "./library/sockjs/sockjs.min.js",
		"stompjs": "./library/stompjs/stomp.min.js"   
	  }
	}
  </script>
  <script src="dist/system.js"></script>
  <script src="dist/extras/amd.js"></script>
  <script src="dist/extras/use-default.js"></script>
  <script src="dist/extras/module-types.js"></script>
  <script src="dist/extras/named-exports.js"></script>
  <script src="dist/extras/named-register.js"></script>
</head>
<body>
	<script>
		function importsMore(argumentList){
			let promiseList = [];
			for (let i = 0; i < argumentList.length; i++) {
			let arg = argumentList[i];
			promiseList.push(
			  new Promise(resolve => {
				System.import(arg).then((o) => {
				  console.log(o);
				  resolve(o);
				});
			  })
			);
			}
			return Promise.all(promiseList);
		}
		
		importsMore(["jquery", "lodash", "sockjs", "stompjs"]).then((libs) => {
			console.log(libs)
      	      	});
		// when i import by the following code , it got same module sometimes
		/*
		System.import("jquery").then((o) => {
		  console.log(o);
		});
		System.import("lodash").then((o) => {
		  console.log(o);
		});
		System.import("sockjs").then((o) => {
		  console.log(o);
		});
		System.import("stompjs").then((o) => {
		  console.log(o);
		});
		*/
	</script>
</body>
</html>

Thanks your working.

@joeldenning
Copy link
Collaborator

Perhaps the most helpful thing would be to create a Code Sandbox that shows the problem - here is a code sandbox template you can start with. Can you show the problem there as a starting place for me to debug this?

@FreezeSoul
Copy link
Author

FreezeSoul commented Jan 30, 2020

You can try on : https://codesandbox.io/s/relaxed-hill-ozorh
Try more times and you will find the problem

@joeldenning
Copy link
Collaborator

I am able to see the issue - will take a look at this later today. Thank you for putting together the code sandbox to demonstrate this

@joeldenning
Copy link
Collaborator

I've discovered that this is being caused by the recent changes to the named-register extra. See https://codesandbox.io/s/serverless-fast-rltnf, #2108, and #2105

@joeldenning
Copy link
Collaborator

After further debugging, it is definitely related to #2104. It's a problem with the AMD extra, but the problem only surfaces when you're also using the named-register extra.

@FreezeSoul
Copy link
Author

Thank you for your working ,waiting for new release!

@joeldenning
Copy link
Collaborator

I've created #2114 to fix this. If you want to try it out in your full application, you can copy/paste the amd and named-register extra into your project and script tag the new versions instead of the 6.1.10 versions to test it out.

@joeldenning
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants