Comments (8)
What is your JsRoutes
configuration?
from js-routes.
i followed the 2.0 upgrade doc, so this is
config/initializers/js_routes.rb
JsRoutes.setup do |config|
config.module_type = nil
config.namespace = "Routes"
end
from js-routes.
I can't reproduce it locally because JS environments are too diverse.
For the sake of debugging can you change the following method locally inside your copy of js-routes
gem to:
isSupported() {
console.log(Root);
console.log(Namespace);
console.log(!!Root);
return true;
},
Line 77 in dba9abe
And then restart the project and tell me if it fixes your issue and what is the output in console?
from js-routes.
I made the changes and this is the console output
routes.js.erb:77 undefined
routes.js.erb:78 Uncaught ReferenceError: Namespace is not defined
at Object.isSupported (routes.js.erb:78:1)
at UtilsClass.is_module_supported (routes.js.erb:476:1)
at UtilsClass.ensure_module_supported (routes.js.erb:479:1)
at UtilsClass.define_module (routes.js.erb:484:1)
at routes.js.erb:1402:1
at Module.<anonymous> (routes.js.erb:1404:1)
at Module../app/javascript/routes.js.erb (routes.js.erb:1406:1)
at __webpack_require__ (bootstrap:84:1)
at Module../app/javascript/packs/application.js (application.js:1:1)
at __webpack_require__ (bootstrap:84:1)
from js-routes.
I tried to fix an issue. Can you try the gem from current master if it solves the problem?
from js-routes.
I tried the gem from current master, and getting this error in routes.js.erb
at
export default this.Routes
Uncaught TypeError: Cannot read properties of undefined (reading 'Routes')
at Module.<anonymous> (0-c0a5c58e421ed5570b29.chunk.js:2025:74)
at Module../app/javascript/routes.js.erb (0-c0a5c58e421ed5570b29.chunk.js:2026:30)
at __webpack_require__ (runtime~application-aa001ceb574a6f67800d.js:80:30)
at Module../app/javascript/packs/application.js (application-96c4f6da898f33e3ba24.chunk.js:170:72)
at __webpack_require__ (runtime~application-aa001ceb574a6f67800d.js:80:30)
at Object.1 (application-96c4f6da898f33e3ba24.chunk.js:2815:18)
at __webpack_require__ (runtime~application-aa001ceb574a6f67800d.js:80:30)
at checkDeferredModules (runtime~application-aa001ceb574a6f67800d.js:46:23)
at Array.webpackJsonpCallback (runtime~application-aa001ceb574a6f67800d.js:33:19)
at application-96c4f6da898f33e3ba24.chunk.js:1:57
from js-routes.
See, there is a kind of problem within webpacker environment: top level this
is equal to undefined
.
The problem is that you need to use one os the following depending on the JS environment: window
, this
or global
.
You need to use this code snippet if you really need that: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#search_for_the_global_across_environments
Overall I do not recommend a configuration like this. It is not environment agnostic.
You should try instead:
JsRoutes.setup do |config|
config.module_type = nil
end
const Routes = <%= JsRoutes.generate %>
export Routes;
from js-routes.
No followup, closing. Feel free to reopen.
from js-routes.
Related Issues (20)
- TypeError: Cannot set property 'NameSpace' of undefined at version 2.0.7 HOT 2
- Don't know how to build task 'js:routes' HOT 9
- Typescript doesn't resolve properly the dynamic routes module HOT 5
- No default export in Typescript definitions file HOT 2
- Automatic updates via rack middleware HOT 5
- Prefer default_url_options over implictly filling with params when passing options hash HOT 2
- module_type: nil causes "NIL is not supported by runtime" HOT 4
- Thoughts for using with webpacker within a Rails engine HOT 2
- Task not found in Rails 7 app HOT 9
- Custom output path HOT 8
- Custom output path HOT 2
- NameError: uninitialized constant JsRoutes::JsRoute HOT 6
- function to get all paths to do custom filtering and selecting? HOT 3
- Error: Cannot read config file: while running yarn lint HOT 3
- Upgrade `rake assets:precompile` to `update js-routes` files in Rakefile did not work for me HOT 13
- ESM Tree shaking not working because __jsr.r() is potentially impure HOT 3
- Use configured Webpacker directory instead of default
- Options style route params HOT 8
- Emoji caused URIError: URI malformed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-routes.