Compile a Polymer app in Dart - javascript

I am using Dart 0.8.10_r30104 (DEV) and find it unable to generate the Javascript (the app itself can run in Dartrium, though).
Errors prompted when I choose to "Generate Javascript" on builder.dart:
--- Nov 12, 2013 7:35:43 AM Running dart2js... ---
F:\dart\dart-sdk\bin\dart2js.bat --out=E:\My Books\Sitepoint\Sample\build.dart.js E:\My Books\Sitepoint\Sample\build.dart
/E:/My Books/Sitepoint/Sample/packages/polymer/builder.dart:83:8: Error: Library not found 'dart:io'.
import 'dart:io';
^^^^^^^^^
/E:/My Books/Sitepoint/Sample/packages/polymer/src/build/linter.dart:11:8: Error: Library not found 'dart:io'.
import 'dart:io';
^^^^^^^^^
/E:/My Books/Sitepoint/Sample/packages/barback/src/asset.dart:9:8: Error: Library not found 'dart:io'.
import 'dart:io';
^^^^^^^^^
...
/E:/My Books/Sitepoint/Sample/packages/analyzer/src/generated/element.dart:7220:17: Hint: The class 'VoidTypeImpl' overrides 'operator==', but not 'get hashCode'.
bool operator ==(Object object) => identical(object, this);
^^
/E:/My Books/Sitepoint/Sample/packages/analyzer/src/generated/element.dart:4874:17: Hint: The class 'PropertyAccessorElementImpl' overrides 'operator==', but not 'get hashCode'.
bool operator ==(Object object) => super == object && identical(isGetter, ((object as PropertyAccessorElement)).isGetter);
^^
Error: Compilation failed.
===
What went wrong?

To generate JS for a polymer app, you need to run "pub build" at the top level of your application. This will create a top level directory called build, which will include your JS (and html that points at the JS).

Related

React Native: Undefined symbol: _swift_stdlib_isStackAllocationSafe in Xcode

I am getting an error after updating Xcode to 13.3.1 in react native. Before upgrading Xcode app was working fine. Also, I haven't changed anything in code. But still I am getting error. I don't why after updating I am getting this error.
Error: Undefined symbol: _swift_stdlib_isStackAllocationSafe
Undefined symbols for architecture arm64:
"_swift_stdlib_isStackAllocationSafe", referenced from:
function signature specialization <Arg[1] = Owned To Guaranteed> of generic specialization <Swift.String, Swift._NativeSet<Swift.String>> of Swift._NativeSet.genericIntersection<A where A == A1.Element, A1: Swift.Sequence>(A1) -> Swift._NativeSet<A> in libLaunchDarkly.a(FlagChangeNotifier.o)
function signature specialization <Arg[1] = Owned To Guaranteed> of generic specialization <Swift.String> of Swift._NativeSet.intersection(Swift._NativeSet<A>) -> Swift._NativeSet<A> in libLaunchDarkly.a(FlagChangeNotifier.o)
function signature specialization <Arg[1] = Owned To Guaranteed, Arg[2] = Owned To Guaranteed> of function signature specialization <Arg[0] = [Closure Propagated : generic specialization <LaunchDarkly.FeatureFlag> of closure #1 (Swift.String) -> Swift.Bool in (extension in LaunchDarkly):Swift.Dictionary< where A == Swift.String>.symmetricDifference(Swift.Dictionary<Swift.String, Any>) -> Swift.Array<Swift.String>, Argument Types : [[Swift.String : LaunchDarkly.FeatureFlag][Swift.String : Any]]> of generic specialization <Swift.String> of Swift._NativeSet.filter((A) throws -> Swift.Bool) throws -> Swift._NativeSet<A> in libLaunchDarkly.a(FlagChangeNotifier.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
react-native": "0.64.2"
Why I am getting this error? And, how can I solve this error?
Have you yet figured this one out? I suspect the Launch Darkly RN SDK is way out of date, as they're still using the older state management form.

Using jQuery with kotlin and gradle (JS backend)

I'm currently trying to get a simple example running in which jQuery can be used by kotlin code compiled to JS with the help of gradle. So far I pieced together the following elements which should be enough according to older descriptions using the kotlin.js.externals:kotlin-js-jquery:3.2.0-0 package by adding it like this to the build.gradle.kts of the project:
repositories {
...
mavenCentral()
maven(url = uri("https://kotlin.bintray.com/js-externals"))
}
dependencies {
implementation("kotlin.js.externals:kotlin-js-jquery:3.2.0-0")
}
After adding the package I can sucessfully import the corresponding kotlin package in a simple Kotlin file like this:
import js.externals.jquery.jQuery
fun main() {
console.log(jQuery("div"))
}
But this sadly fails if executed with the following stack trace in the JS console:
Uncaught TypeError: $module$jquery is not a function
at main (simple.kt?9d2a:4)
at Object.eval (yet_another_one.js:14)
at eval (yet_another_one.js:5)
at eval (yet_another_one.js:8)
at Object../kotlin-dce-dev/yet_another_one.js (yet_another_one.js:515)
at __webpack_require__ (yet_another_one.js:30)
at Object.0 (yet_another_one.js:527)
at __webpack_require__ (yet_another_one.js:30)
at yet_another_one.js:94
at yet_another_one.js:97
After this I checked the packages webpack used for the bundling and I found out that as soon as the kotlin.js.externals:kotlin-js-jquery:3.2.0-0 package is used the following jquery.js file gets used instead of the one with the actual code:
(function (root, factory) {
if (typeof define === 'function' && define.amd)
define(['exports', 'kotlin'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('kotlin'));
else {
if (typeof kotlin === 'undefined') {
throw new Error("Error loading module 'jquery'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'jquery'.");
}
root.jquery = factory(typeof jquery === 'undefined' ? {} : jquery, kotlin);
}
}(this, function (_, Kotlin) {
'use strict';
Kotlin.defineModule('jquery', _);
return _;
}));
//# sourceMappingURL=jquery.js.map
As this looks a bit strange to me as the jquery code seems not to be found anywhere I also tried adding it as a NPM dependency to the build.gradle.kts like this:
dependencies {
...
implementation(npm("jquery", "3.6.0"))
}
But doing so didn't change a thing. Webpack still uses the jquery.js file shown above (and maybe rightfully so), but it also still doesn't work.
I would appreciate any help to get this working as I already invested a lot of time in it and I'm currently kinda hopeless :(.
Thanks a lot!
To create a simple example, start a multiplatform project from the IntelliJ IDEA:
Select: File -> New Project
In the new window on the left hand select: Kotlin
In the main pane select the project template "Full-stack Web Application"
Use Build-System "Gradle Kotlin" to have best compatibility.
After this, Dukat is installed to generate your externals for jQuery:
Simply go to build.kts (your gradle build file) and under dependencies of jsMain add:
val jsMain by getting {
dependencies {
/// ... ommitted pre-installed directives
implementation(npm("#types/jquery","3.5.1", generateExternals = true))
implementation(npm("jquery","3.5.1"))
}
}
After this you can simply access jquery using jQuery as a static import:
import jQuery
And use it like a kotlin library: val xhr = jQuery.get("http://example.com")

Can Cypress run test files imported outside of Cypress folder?

I'm working on an E2E test framework using Cypress, and wanted to import spec files which are outside the Cypress directory (containing dir for: fixtures, integration, plugins, support). When I started some initial tests to verify if it would work as expected, I get these error messages stating that the error originate from my test code, not Cypress. The cause of the error is a TypeError stating: Cannot read property 'includes' of undefined.
Internet searches on this issue weren't really helpful, since no else seemed to have trouble with this behavior, (at least from my perspective). Even when I moved the spec file I selected as an import into cypress/integration/, the same issue repros.
At this point I'm stumped at what's the cause of this problem and how to resolve it. Is there something I'm missing?
Here is what I got in package.json (devDependencies, and field for main):
"main":"index.js",
"devDependencies": {
"#cypress/webpack-preprocessor": "^5.4.1",
"cypress": "^4.9.0",
"selenium-webdriver": "^4.0.0-alpha.7",
"webpack": "^4.43.0"
}
My spec which imports spec file outside of Cypress directory (cypress/integration/RunE2ETest.spec.js):
import '../../Cypress_E2E_Example/SteamHeader.spec';
The spec file outside of Cypress folder (SteamHeader.spec) just showing how I have it set with imports, exports:
import '../Cypress-E2E/BaseTest';
export default describe('Test Suite for ....' () => {
it('test example'), () => {
}
}
The file for my BaseTest:
import default before('BaseSetup', () => {
cy.visit('/');
}
Details on error:
Line causing the error (node_modules/global-dirs/index.js:28:1):
26 |
27 | // Homebrew special case: `$(brew --prefix)/lib/node_modules/npm/npmrc`
> 28 | if (process.execPath.includes('/Cellar/node')) {
| ^
29 | const homebrewPrefix = process.execPath.slice(0, process.execPath.indexOf('/Cellar/node'));
30 | return path.join(homebrewPrefix, '/lib/node_modules/npm/npmrc');
31 | }
Stacktrace:
We dynamically generated a new test to display this failure.
at getGlobalNpmrc (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86028:23)
at getNpmPrefix (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86064:30)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86072:32)
at Object.512._process (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:86120:4)
at o (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:265)
at eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:316)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:89116:20)
at Object.551.fs (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:89130:4)
at o (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:265)
at eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:316)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:70417:28)
at Object.425../fs (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:70842:4)
at o (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:265)
at eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:1:316)
at Object.eval (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:67474:12)
at Object.411../lib/cypress (https://store.steampowered.com/__cypress/tests?p=cypress\integration\RunE2ETest.spec.js:67503:4)
We experienced the same error. It was caused by an import of the cypress module. I guess this module is not intended to be imported in files which are loaded in the browser.

Migration to the angular v9. i18n breaking changes

I'm migrating an Angular project from 8.2.14 to the 9.0.0-rc.14. Using i18n for localization.
I followed the guide here https://update.angular.io/#8.2:9.0 and it feels it went fine. After the upgrade, I'm trying to run the project, but
ng serve leads to the following error:
An unhandled exception occurred: An i18n locale ('en-US') cannot both be a source locale and provide a translation.
See "...my local logs path...\angular-errors.log" for further details.
In the angular-errors.log the error is more detailed:
[error] Error: An i18n locale ('en-US') cannot both be a source locale and provide a translation.
at createI18nOptions (...my project path...\node_modules\#angular-devkit\build-angular\src\utils\i18n-options.js:69:23)
at Object.configureI18nBuild (...my project path...\node_modules\#angular-devkit\build-angular\src\utils\i18n-options.js:100:18)
at process._tickCallback (internal/process/next_tick.js:68:7)
I have got more details about the error: opening the #angular-devkit\build-angular\src\utils\i18n-options.js:69:23 and I see the following logic:
if (locale === i18n.sourceLocale) {
throw new Error(`An i18n locale ('${locale}') cannot both be a source locale and provide a translation.`);
}
I have en-US locale and I want to continue using it as both translation and source. So how to fix this breaking error?
I assume your default language is different than English.
Thus, you should have change the default source 'sourceLocale' as shown in the official docs.
So it would be like:
"projects": {
"AngularApp": {
"i18n": {
"sourceLocale": "he-IL",
"locales": {
"en-US": "src/locale/messages.en.xlf"
}
},
...
simply open your angular.json file and remove the entry under locales which you have set under "sourceLocale". After the update locales only stores the translation not the language that you use in your source code.
Exactly, as #Markus said:
Your original language (developer) must not appear in '"locales": '.
Only in '"sourceLocale": '.

Undefined reference to require and exports while using Typescript in gulp and nodejs

I used to write my web application in plain javascript until I go to know Typescript. Its a good superset of javascript and i didnt have any problem if i write and compile it, and execute it using my WAMP server.
But i heard about angular2( i know angular1 ), i started learning it using https://www.lynda.com/AngularJS-tutorials/Learn-AngularJS-2-Basics/428058-2.html course.
He uses nodejs, gulp, gulp-webserver. I did exact setup as he did, but at the end i got
Uncaught ReferenceError: exports is not defined # animal.ts:1.
Uncaught ReferenceError: require is not defined # cat.ts:1
Then i switched to first learning how to setup gulp environment from https://www.youtube.com/watch?v=7xOubdqyqaY
here's my project directory structure :
typescript/
|--app/
----index.html, load animal.js, cat.js from js/
----|--js, contains all compiles js files( animal.js, cat.js )
-------|--lib, contains all library files
|--node_modules/
|--typescript/, contains my written typescript files
---|--animal.ts
---|--cat.ts
|--typing/s, contains typescript definition files
|--gulp.config.js
|--gulpfile.js
|--package.json
|--tsconfig.json
|--tslint.json
when i run gulp command in cmd at root folder(typescript), it runs all the tasks, it compiles all ts files, lint it and serves it using browser-sync and superstatic. However i got same error
Uncaught ReferenceError: exports is not defined # animal.ts:1.
Uncaught ReferenceError: require is not defined # cat.ts:1
my files content :
animal.ts
export class Animal {
constructor( private name: string, private sound: string ) {
}
makeSound() {
console.log( `${this.name} makes ${this.sound}` );
}
}
let a: Animal = new Animal( "tiger33", "Gurrrrrr" );
a.makeSound();
cat.ts
import {Animal} from "./animal"
let b: Animal = new Animal( "Cat", "Mewww" );
b.makeSound();
Please tell me what am i doing wrong.
I have node, gulp, tsc installed globally.
Do i need to install browserify or requireJS, but in video they are not using any of this.
Thank you
Finally got it working using Browserify.
Steps here.

Categories