Ember-simple-auth with ember-cli-simple-auth-token - javascript

I'm trying to use ember-simple-auth with ember-cli-simple-auth-token:
"ember-cli-simple-auth-token": "^0.7.3",
"ember-simple-auth": "1.0.1"
And that's my configurations:
ENV['simple-auth-token'] = {
authorizer: 'simple-auth-authorizer:token',
identificationField: 'email',
serverTokenEndpoint: 'http://localhost:3000/token'
};
Am i missing something? Cause i'm receiving this error in my console:
Could not find module simple-auth/authenticators/base imported from simple-auth-token/authenticators/token
I already try to uninstall and npm prune, and reinstall.. and the same message keeps showing.
Thanks guys.

No - simple-auth-token hasn't been updated as yet. A couple of minor changes seems to get it going again, which I will post to the author.
The changes in the ember-simple-auth-token module required are:
1) app/initializers/simple-auth.js:
change "simple-auth" on line 1 to "ember-simple-auth" and
remove (or comment out) lines 2 and 9 (the import for setup, and the call
to setup).
2) addon/authenticators/token.js:
change "simple-auth" on line 2 to "ember-simple-auth"
3) addon/authorizers/token.js:
change :simple-auth" on line 2 to "ember-simple-auth"
Hopefully that helps a few people out there struggling with this.
Cheers!

The name of the addon is ember-simple-auth and it's looking for a path simple-auth/authenticators/base which should be ember-simple-auth/authenticators/base. You should correct that import in the file simple-auth-token/authenticators/token.

Related

How to debug Rollup build output with a massive encoding log?

I recently built a library with Rollup that has a few non-usual bits. That includes for instance, loading up a wasm module, workers with importScripts and a few occurences of eval() in the global scope.
Now I used the rollup-starter-app to create a demonstrator and client app for that library. The repo is https://github.com/frantic0/sema-engine-rollup
I managed to get everything working, after hitting a few walls and adding the following rollup plugins
import { wasm } from "#rollup/plugin-wasm";
import workerLoader from "rollup-plugin-web-worker-loader";
import dynamicImportVars from "#rollup/plugin-dynamic-import-vars";
import copy from "rollup-plugin-copy";
However, in the build output, I'm getting this massive log of what seems to be some encoding...
I'm not sure where this log is coming from and it is so massive that it clears out all the information of the build in the terminal...
What is the best way to tackle this issue and how to debug it effectively?
based on the suggestion #lukastaegert on the rollup issues, one solution is to redirect stderr into a file to read the log.
To do that you can add the following to your rollup command
"rollup -cw 2>err.log 1>out.log"
this allows to further inspect the build log but doesn't solve the error
[EDIT]
After a bit of peeking around Rollup's github issues and source, I found the warning categories and how to deactivate warnings.
Basically, we need to add a function onwarn to rollup.config.js. The first code section below shows the function. The second one show where we should add it on the rollup.config.js
const onwarn = (warning) => {
// Silence warning
if (
warning.code === 'CIRCULAR_DEPENDENCY' ||
warning.code === 'EVAL'
) {
return
}
console.warn(`(!) ${warning.message}`)
}
export default {= {
inlineDynamicImports: !dynamicImports,
preserveEntrySignatures: false,
onwarn,
input: `src/main.js`,
output: {

react-monaco-editor blackout... TypeError: Cannot read property 'pushUndoStop' of undefined

I use "react-monaco-editor" for my project.
import { MonacoDiffEditor } from 'react-monaco-editor';
...
<MonacoDiffEditor
width="1140"
height="520"
language="javascript"
theme="vs-dark"
original={this.props.original}
value={this.props.current}
options={{
renderSideBySide: true,
}}
editorDidMount={this.editorDidMount}
/>
This error can only be viewed after deploy my server.
simpleWorker.js:25 Could not create web worker(s). Falling back to
loading web worker code in main thread, which might cause UI freezes.
Please see https://github.com/microsoft/monaco-editor#faq el #
simpleWorker.js:25 simpleWorker.js:28 You must define a function
MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker el #
simpleWorker.js:28 react-dom.production.min.js:5058 TypeError: Cannot
read property 'pushUndoStop' of undefined
at l.value (diff.js:283)
at ls (react-dom.production.min.js:5163)
at react-dom.production.min.js:6408
at t.unstable_runWithPriority (scheduler.production.min.js:309)
at Ui (react-dom.production.min.js:2816)
at Cl (react-dom.production.min.js:6204)
at cl (react-dom.production.min.js:5895)
at react-dom.production.min.js:2851
at t.unstable_runWithPriority (scheduler.production.min.js:309)
at Ui (react-dom.production.min.js:2816) rs # react-dom.production.min.js:5058
I test in local with nginx, but only serviceWorker warnings logged.
I think that ServiceWorker warnings are http environment in my server.
What is pushUndoStop... I really don't know this error.
help me...
Not sure if you fixed this issue or not by now, since it has been a while, but in case anyone else lands here, I got this issue too. I had v0.20.0 of monaco-editor and v0.35.0 react-monaco-editor which worked fine. Then I updated to v0.23.0 and I ran into this issue as a regression. I then tried v0.25.2 with no change. After that I tried updating react-monaco-editor to the v0.43.0 and the problem stopped happening! I'm thinking it is an issue where they made a change in monaco-editor and if you didn't update react-monaco-editor to a newer version it would break with that error.

React library that uses flow causes issues

I am relatively new to js & react so please bear with me!
I started a new project using create-react-app and react 16.12.0. I installed a library which I guess uses flow.
Trying to use this (npm install) library gives me the following SynatError:
./node_modules/react-resize-aware/src/useResizeAware.js
SyntaxError: [...]\node_modules\react-resize-aware\src\useResizeAware.js: Unexpected token, expected "," (5:31)
3 | import ResizeListener from './ResizeListener';
4 |
> 5 | const defaultReporter = (target: ?HTMLElement) => ({
| ^
6 | width: target != null ? target.offsetWidth : null,
7 | height: target != null ? target.offsetHeight : null,
8 | });
I feel like this is an issue on my side or at least an issue I could fix by doing some changes to the project's package.json.
If so, I would be happy if you could explain to me how.
//EDIT:
I tried adding flow to my project as described here but it gives me the same error.
What works is copying the source of the library into my project and importing it from this local version.
But I would really like to use the npm package, and not maintain a local version of the lib myself.
Thank you so much in advance!
Silly me, I simply imported from the wrong path. I used
import moduleName from "lib-name/src";
instead of
import moduleNamefrom "lib-name";

Ember build error that is happening on adding a route that has an ajax request

So here are the details. I'm running the code on a mac. The code was originally built on ubuntu. This wasn't a problem on ember till date.
ERROR -
ENOENT: no such file or directory, lstat
'/Users/...emberapp/tmp/funnel-input_base_path-nz4m8qQr.tmp/index.html'
and below that, this...
Error: ENOENT: no such file or directory, lstat
'/Users/flyn/Documents/working local/backend
dashboard/tmp/funnel-input_base_path-xjJozhFY.tmp/index.html'
at Error (native)
This is the route that's causing the issue. The ajax call works independently when called on browser when running this:
http://localhost:4300/getRecords?by_param=by_usage&include_docs=true&key_type=%20
This is the code on routes.
import Ember from 'ember';
export default Ember.Route.extend({
ajax: Ember.inject.service(), model(){ return
this.get("ajax").request("http://localhost:4300/getRecords", {
data: {
"by_param": "by_usage",
"key_type": "",
"include_docs": true,
"key_value": {}
}
}).then(function(usr) {
// return usr.rows.data;
var ar = []
for (var i=0; i<usr.rows.length; i++){
ar.push(usr.rows[i].doc.data);
}
return ar
});
}
});
Now here's what I did. I removed the ajax call entirely to see if it works after that. It didn't. Then I did (in a very similar naming convention for the route name, with a hyphen -) ...
ember -d route route-name
now it works. Built the route again, added the ajax. It continues working. Close the server and restart, it stops working.
Finally, an additional note.
I saw a similar error on this link
But I already have watchman, which wasn't an issue before, and the first answer (not comment) suggests some ideas, which I'm not sure what that meant.
Thank you
I add a similar issue, have you tried to clear the watchman-list ? it helped me (after a restart of the computer or restart of sublime text) all was working well but sometimes the issue was still there.

webpack2 dynamic style file require

I am working with webpack 2 and I want to include some style file that depends from different NODE_ENV.
I did something like this:
const stylesEntryName = process.env.SECOND_CLIENT ? "main_for_second_client" : "main";
const entryUrl = `assets/styles/${stylesEntryName}.styl`;
console.log("stylesEntryName ====>>> ", stylesEntryName, entryUrl);
require(entryUrl);
But it isn't working somehow. I have got an error: Critical dependency: the request of a dependency is an expression
the console shows: stylesEntryName ====>>> main assets/styles/main.styl
Maybe I do something wrong? (in case of direct url)
require('assets/styles/main.styl');
the code working fine.
Thanks for any help.
webpack is emitting that warning about the line require(entryUrl) because the value of the entryUrl variable is unknown until the code is executed (i.e., the require is not statically analyzable). Here's the webpack documentation about that: https://webpack.github.io/docs/context.html#critical-dependencies
You can fix this problem by removing the dynamic require, and instead use if-else statements to pick a static require statement out of the possible choices. Here's code that does that for your issue:
if (process.env.SECOND_CLIENT === 'main_for_second_client') {
require('assets/styles/main_for_second_client.styl')
} else {
require('assets/styles/main.styl')
}

Categories

Resources