So I have a react component that I'm trying to publish into npm registry.
It is a simple component, that decides what component to render, and all the options to render are created by others in my corporation and imported from npm registry.
The problem is, that when I build my component, and try to use it, it does not work and gives me the next error:
./node_modules/#corp/foo/dist/component.es.js
SyntaxError: /Users/225336/Documents/corp/projektit/react-test-
app/test-app/node_modules/#corp/component/dist/component.es.js: Identifier
'___$insertStyle' has already been declared (86:9)
84 | }
85 |
> 86 | function ___$insertStyle(css) {
| ^
When I look into component.es.js, I see that it creates ___$insertStyle(css) function, for every imported component and one for my parent component, but the first two does not have identification numbers after them and so they overlap
function ___$insertStyle(css) {
if (!css) {
return;
}
if (typeof window === 'undefined') {
return;
}
var style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.innerHTML = css;
document.head.appendChild(style);
return css;
}
...
function ___$insertStyle(css) {
if (!css) {
return;
}
if (typeof window === 'undefined') {
return;
}
var style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.innerHTML = css;
document.head.appendChild(style);
return css;
}
___$insertStyle(".1-embed-container...");
...
function ___$insertStyle$1(css) {
...
}
...
___$insertStyle$1(".2-embed-container...");
...
function ___$insertStyle$2(css) {
...
}
...
___$insertStyle$2(".at-embed{padding:14px;line-height:1.4;font-family:Bernino Sans,Verdana,sans-serif}.at-embed div{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.at-embed h4{margin:0 0 5px}.at-embed h6{margin:0;font-size:13px;font-weight:700}.at-embed img{display:none}.at-embed article{border-left:4px solid #999;padding:2px 0 2px 10px;margin-bottom:10px;clear:both}.at-embed article,.at-embed article:first-child{-webkit-flex:1 0 100%;-ms-flex:1 0 100%;flex:1 0 100%;margin-right:20px}.at-embed article:first-child{margin-bottom:20px;border:0;padding:0}.at-embed article:first-child a{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start}.at-embed article:first-child h6{font-size:15px;line-height:1.2}.at-embed article:first-child img{display:block;margin-right:14px;width:40%}.at-embed article:last-child{margin:0}#media (min-width:420px){.at-embed article:first-child h6{font-size:18px}}#media (min-width:840px){.at-embed article{-webkit-flex:1 1 135px;-ms-flex:1 1 135px;flex:1 1 135px;border:0;padding:0}.at-embed article img{display:block;margin:0 0 10px}.at-embed article:first-child h6{font-size:22px}}.at-embed-kl article{border-color:#00c4e0}.at-embed-te article{border-color:#eb1c22}.at-embed-mb article{border-color:#4068ad}.at-embed-mb svg path{fill:#4068ad}");
...
What could cause it and how could i fix it?🤔
Removing manually one of the duplicate functions fixes the problem, but that isn't obviously the right way.
"Fixed" it by using webpack instead of rollup.
Related
I´m a technical project manager coordinating developers. My coding skills are limited and so I align with my devs on logical structure. For a mobile app (React Native to serve Android and iOS) we are currently developing user current location logic. Turned out we have specific Android and iOS settings, what may require native developmetn for location service handling.
I´m currently reviewing the following pseudocode and, besides others, concerned about the MULTIPLE IF statements and thinking if there is a more efficient way, as here we seem to jump into every IF, even when location is set already before.
I think there can be something like "until", "break" or similar .. and maybe relevant to consider the specific dev language, React Native in that case?
Any help, as pseudocode or if possible to make it specific already considering React Native, is very much appreciated.
Many thanks in advance!
Code
////Central Location Service to get current location.
var currentLocation;
var locationType
if Android {
DEFINED_ACCURACY = QUALITY_BALANCED_POWER
} else id iOS {
DEFINED_ACCURACY = kCLLocationAccuracyHundredMeters
}
DEFINED_DISTANCE = 3000
function startLocationService(){
var locationservice = LocationService()
locationservcie.accuracy = DEFINED_ACCURACY
locationservcie.distance = DEFINED_DISTANCE
locationservcie.startListnertoLocationUpdate() {
cacheData(location, currentTime);
currentLocation = location
}
}
function getLocationFromLocationService() {
if locationServcieEnabled == false
return NULL;
if locationPermissionGranted == false
return NULL;
return currentLocation;
}
function getCurrentLocation() {
var lcoation = NULL;
var accuracy = Not_defined;
lcoation = getLocationFromLocationService() //GPS, network
locationType = locationService
if lcoation == NULL {
locationdata == getLastKnownLocation()
if locationdata.Age < DEFINED_DURATION {
location = locationdata.location
locationType = locationService
}
}
if location == NULL {
location == getCachedLocationWithin24Hour()
locationType = locationService
}
if location == NULL {
location = getLocationfromTelephony()
locationType = other
}
if location == NULL {
if permissionToUseBilling == false {
askForPermissionToUseBilling()
}
location = getLocationFromBillimg()
accuracy = other
}
if location == NULL {
location = getLocationOfDEfaultCountry()
accuracy = other
}
return location, Other
}
I think you can use switches to cover different cases from javascript.
Probably your dev team knows, but did not want to bring it into pseudo code?
const location = getLocationFromLocationService() ;
switch (location) {
case 'NULL':
//DO SOMETHING WHEN NULL;
break;
case 'New York':
// DO SOMETHING WHEN New York;
// No break leads to run also into the next case
case 'Bern':
console.log('I love nice cities.');
break;
default:
console.log(`Sorry, we are out of ${location}.`);
}
Interestingly you seem to have multiple times the same if case?
Maybe you will to nest it or have to use a switch with multiple expressions.
case ("Bern" && "ANOTHERExpression to be true"):
Link to switch documentation
Please don't underestimate your dev team. ;-)
I have the following function which gives me an array called URLs
const storageRef = this.$fire.storage.ref().child(fileName)
try {
const snapshot = storageRef.put(element).then((snapshot) => {
snapshot.ref.getDownloadURL().then((url) => {
urls.push(url)
})
})
console.log('File uploaded.')
} catch (e) {
console.log(e.message)
}
});
console.log(urls)
console.log("about to run enter time with imageurls length " + urls.length)
When I run console.log(URLs) initially I do see the array like the following
[]
0: "testvalue"
length: 1
__proto__: Array(0)
However, there is a small information icon stating
This value was evaluated upon first expanding. The value may have changed since.
Because of this, when I try to get the length of URLs, I get zero, meaning the value is being updated.
Does anyone know what's happening? I am using Vue.JS/Nuxt.
I am attempting to send data from Elm 0.19 to JavaScript using ports.
Edit: The problem seems to be related to running/building with elm-app
In Elm, I declare an outgoing port:
port modelToJs : Json.Encode.Value -> Cmd msg
which I use in the update function to produce a Cmd that sends a JSON encoded value to JavaScript.
In JS, I instantiate the Elm app:
const app = Elm.Main.init({
node: document.getElementById('root')
});
and register the data handler:
app.ports.modelToJs.subscribe(function dataHandler(data) {
console.log("got from Elm:" + data);
});
When modelToJs is called, the data is not sent and printed to the console. Instead, I get the following JavasScript runtime error (which Elm claims to avoid by design):
TypeError: currentSubs[i] is not a function
var value = _Json_unwrap(converter(cmdList.a));
2160 | for (var i = 0; i < currentSubs.length; i++)
2161 | {
> 2162 | currentSubs[i](value);
2163 | }
2164 | }
2165 | return init;
I have also provided a full proof of concept project on GitHub: https://github.com/mpgirro/elm0.19-ports-issue
The repo also contains an image of the error message (sry, I lack the reputation to post images)
The error appears to be in dataHandler.js. It currently contains this:
function dataHandler(data) {
console.log("got from Elm:" + data);
}
If you declare the function as export default the problem goes away:
export default function dataHandler(data) {
console.log("got from Elm:" + data);
}
I just installed LDAP and PHPLDAPADMIN.Its work fine but when I want Create new entry page just refresh and nothing happend.There are a few errors:
Unrecognized error number: 8192: Function create_function() is deprecated
Errors in phpldapadmin
Thank you.
Try this code working fine.
/usr/share/phpldapadmin/lib/functions.php on line 54
change line 54 to
function my_autoload($className) {
Add this code on line 777
spl_autoload_register("my_autoload");
change line 1083 to
$CACHE[$sortby] = __create_function('$a, $b',$code);
add the code below on line 1091 from the
function __create_function($arg, $body) {
static $cache = array();
static $maxCacheSize = 64;
static $sorter;
if ($sorter === NULL) {
$sorter = function($a, $b) {
if ($a->hits == $b->hits) {
return 0;
}
return ($a->hits < $b->hits) ? 1 : -1;
};
}
$crc = crc32($arg . "\\x00" . $body);
if (isset($cache[$crc])) {
++$cache[$crc][1];
return $cache[$crc][0];
}
if (sizeof($cache) >= $maxCacheSize) {
uasort($cache, $sorter);
array_pop($cache);
}
$cache[$crc] = array($cb = eval('return
function('.$arg.'){'.$body.'};'), 0);
return $cb;
}
finally restart your apache server sudo service apache2 restart
PhpLdapAdmin uses a few functions which are deprecated in PHP 7.2. Take a look at this fix:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890127
What's the best way to receive 'hidden' input from a command-line Dart application? For example, in Bash, this is accomplished with:
read -s SOME_VAR
Set io.stdin.echoMode to false:
import 'dart:io' as io;
void main() {
io.stdin.echoMode = false;
String input = io.stdin.readLineSync();
// or
var input;
while(input != 32) {
input = io.stdin.readByteSync();
if(input != 10) print(input);
}
// restore echoMode
io.stdin.echoMode = true;
}
This is a slightly extended version, key differences are that it uses a finally block to ensure the mode is reset if an exception is thrown whilst the code is executing.
The code also uses a waitFor call (only available in dart cli apps) to turn this code into a synchronous call. Given this is a cli command there is no need for the complications that futures bring to the table.
The code also does the classic output of '*' as you type.
If you are doing much cli work the below code is from the dart package I'm working on called dcli. Have a look at the 'ask' method.
https://pub.dev/packages/dcli
String readHidden() {
var line = <int>[];
try {
stdin.echoMode = false;
stdin.lineMode = false;
int char;
do {
char = stdin.readByteSync();
if (char != 10) {
stdout.write('*');
// we must wait for flush as only one flush can be outstanding at a time.
waitFor<void>(stdout.flush());
line.add(char);
}
} while (char != 10);
} finally {
stdin.echoMode = true;
stdin.lineMode = true;
}
// output a newline as we have suppressed it.
print('');
return Encoding.getByName('utf-8').decode(line);
}