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

TypeError: Cannot set property 'NameSpace' of undefined at version 2.0.7 #281

Closed
tashirosota opened this issue Jul 13, 2021 · 2 comments
Closed

Comments

@tashirosota
Copy link

tashirosota commented Jul 13, 2021

Ruby: 2.6.6
Rails: 6.1.3
Raise TypeError: Cannot set property 'NameSpace' of undefined when I tried for update to 2.0.7 from 1.4.14

# setup & generate
JsRoutes.setup do |config|
  config.module_type = 'UMD'
  config.namespace = 'RailsRoutes'
  config.documentation = false
end
JsRoutes.generate! path, options
  • Where
// 2.0.7
// Raise in rails-routes.js
debugger
Utils.namespace(Root, "RailsRoutes", result);

// In console
$ Root
 => undefined
$ thas
 => undefined

// 1.4.14
// Raise in rails-routes.js
if (typeof define === "function" && define.amd) {
  define([], function() {
    return result;
  });
} else if (typeof module !== "undefined" && module !== null) {
  try {
    module.exports = result;
  } catch (error1) {
    error = error1;
    if (error.name !== 'TypeError') {
      throw error;
    }
  }
} else {
  debugger // Can not reach this line
  Utils.namespace(Root, "RailsRoutes", result);
}

Is this implementation out of place?

if (typeof define === "function" && define.amd) {
  define([], function() {
    return result;
  });
} else if (typeof module !== "undefined" && module !== null) {
  try {
    module.exports = result;
  } catch (error1) {
    error = error1;
    if (error.name !== 'TypeError') {
      throw error;
    }
  }
} else {
  Utils.namespace(Root, "RailsRoutes", result);
}
@bogdan
Copy link
Collaborator

bogdan commented Jul 19, 2021

If you are using UMD module type, you'd probably need to remove namespace option. This option is only valuable if module_type is nil.

@tashirosota
Copy link
Author

@bogdan
Thanks!!!I resolved!!

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