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

runtime require inconsistency #67

Closed
GordonSmith opened this issue Oct 19, 2017 · 4 comments
Closed

runtime require inconsistency #67

GordonSmith opened this issue Oct 19, 2017 · 4 comments

Comments

@GordonSmith
Copy link
Contributor

GordonSmith commented Oct 19, 2017

<edit - I initially thought this was an IE11 issue, but I can reproduce in chrome>

Opening the sample application test page fails when locale is set to en-gb (https://openntf.github.io/dojo-webpack-plugin-sample/test.html):

Error: Module not found: dojo/cldr/nls/en-gb/gregorian
   {
      [functions]: ,
      __proto__: { },
      description: "Module not found: dojo/cldr/nls/en-gb/gregorian",
      message: "Module not found: dojo/cldr/nls/en-gb/gregorian",
      name: "Error",
      stack: "Error: Module not found: dojo/cldr/nls/en-gb/gregorian
   at d (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:895)
   at Anonymous function (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:1294)
   at l (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:1265)
   at i (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:123)
   at Anonymous function (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:102282)
   at l (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:1265)
   at i (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:123)
   at g (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:102212)
   at Anonymous function (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:102947)
   at s.forEach (https://openntf.github.io/dojo-webpack-plugin-sample/release/bundle.js:1:15942)"
   }

Steps to reproduce:
Add the following locale override to dojo config:

        locale: "en-gb",        

Rebuild and open.

There are two issue going on, the missing locale is covered by: https://github.com//issues/69 and this issue will focus on the inconsistent behaviour of the runtime require call.
@GordonSmith GordonSmith changed the title IE11 + nls issue nls issue Oct 19, 2017
@GordonSmith
Copy link
Contributor Author

FWIW I think its an issue with the webpack require implementation and the following "quick fix" in DojoAMDMainTemplate.runtime.js appears to work:

	function req(config, dependencies, callback) {
		try {
			return contextRequire(config, dependencies, callback, 0, req);
		} catch (e) {
			if (dependencies) {
				dependencies();
			}	
			return null;
		}	
	}

GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 19, 2017
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 19, 2017
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 19, 2017
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 19, 2017
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 19, 2017
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 19, 2017
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 19, 2017
In WebPack calling require([x, y, z]), callback); where "y" does not exist, throws an exception.

In Dojo the same call would still callback with a valid x + z.

Fixes OpenNTFGH-67

Signed-off-by: Gordon Smith <[email protected]>
chuckdumont added a commit that referenced this issue Oct 19, 2017
GH-67 Unexpected webpack require behaviour
@chuckdumont chuckdumont reopened this Oct 19, 2017
@chuckdumont
Copy link
Collaborator

Re-opening this because I don't believe we have it quite right yet. Dojo doesn't throw an exception in the require call if a require dependency cannot be loaded, but it also does not call the require callback if any of the modules cannot be loaded and initialized.

Please create a new PR to fix this. You could revert the change you made to findModule() so that it always throws again, and surround the call to findModule() in contextRequire() with a try/catch block and set a flag if an exception is caught, then only call the require callback if the flag has not been set. You'll also need to update the unit test. Thanks.

@GordonSmith
Copy link
Contributor Author

I will do - (and I did just sanity check the above behavior and can confirm it is correct for my en-gb scenario).

FWIW I was basing my observed behavior on the "define" section. Not the runtime require case!

I have opened a new issue: #69 which more accurately describes my original issue, and have edited this issue to reflect the issue we are currently fixing.

@GordonSmith GordonSmith changed the title nls issue runtime require inconsistency Oct 20, 2017
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 20, 2017
Rollback OpenNTFGH-67 changes
Calling require([x, y, z], callback) where any module is missing, should _not_
call the callback or throw an exception.

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 20, 2017
Rollback OpenNTFGH-67 changes
Calling require([x, y, z], callback) where any module is missing, should _not_
call the callback or throw an exception.

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 20, 2017
Rollback OpenNTFGH-67 changes
Calling require([x, y, z], callback) where any module is missing, should _not_
call the callback or throw an exception.

Signed-off-by: Gordon Smith <[email protected]>
GordonSmith added a commit to GordonSmith/dojo-webpack-plugin that referenced this issue Oct 23, 2017
Rollback OpenNTFGH-67 changes
Calling require([x, y, z], callback) where any module is missing, should _not_
call the callback or throw an exception.

Signed-off-by: Gordon Smith <[email protected]>
chuckdumont added a commit that referenced this issue Oct 23, 2017
@chuckdumont
Copy link
Collaborator

Runtime require error handling an unit tests added with #71

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