WDS Warnings while compiling - webpack-dev-server

If I define a bare scalajs build.sbt as below with no actual scala code (App is an empty class):
enablePlugins(ScalaJSBundlerPlugin)
lazy val repro = project.in(file(".")).settings(
name := "Repro",
scalaVersion := "2.12.8",
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.6"
),
mainClass in Compile := Some("App"),
scalaJSUseMainModuleInitializer := true,
webpackDevServerPort := 3000
)
with the following two plugins:
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.15.0")
Then whenever I rung fastOptJS::startWebpackDevServer I get a pile of warnings like below. Is there anything I can do to get rid of these warnings?
[WDS] Warnings while compiling. client:147
./repro-fastopt.js (Emitted value instead of an instance of Error)
Cannot find source file
'https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Boolean.scala':
Error: Can't resolve
'./https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Boolean.scala'
in '/home/des/workspace/repro/target/scala-2.12/scalajs-bundler/main'
# multi (webpack)-dev-server/client?http://localhost:3000
./repro-fastopt.js client:153
./repro-fastopt.js (Emitted value instead of an instance of Error)
Cannot find source file
'https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Byte.scala':
Error: Can't resolve
'./https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Byte.scala'
in '/home/des/workspace/repro/target/scala-2.12/scalajs-bundler/main'
# multi (webpack)-dev-server/client?http://localhost:3000
./repro-fastopt.js client:153
./repro-fastopt.js (Emitted value instead of an instance of Error)
Cannot find source file
'https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Character.scala':
Error: Can't resolve
'./https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Character.scala'
in '/home/des/workspace/repro/target/scala-2.12/scalajs-bundler/main'
# multi (webpack)-dev-server/client?http://localhost:3000
./repro-fastopt.js client:153
./repro-fastopt.js (Emitted value instead of an instance of Error)
Cannot find source file
'https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Class.scala':
Error: Can't resolve
'./https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Class.scala'
in '/home/des/workspace/repro/target/scala-2.12/scalajs-bundler/main'
# multi (webpack)-dev-server/client?http://localhost:3000
./repro-fastopt.js client:153
./repro-fastopt.js (Emitted value instead of an instance of Error)
Cannot find source file
'https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Double.scala':
Error: Can't resolve
'./https://raw.githubusercontent.com/scala-js/scala-js/v1.0.0-M7/javalanglib/src/main/scala/java/lang/Double.scala'
in '/home/des/workspace/repro/target/scala-2.12/scalajs-bundler/main'
...

Related

React native with haul not working, throwing some loader issue

I have added haul to my react native project to analyze why my release build fails. but I got another problem instead. I have a webpack.haul.js with following config
module.exports = {
entry: './index.js',
};
When i run react-native run-android i see the following error. Can someone help me please.
ERROR Failed to compile.
./node_modules/native-base-shoutem-theme/src/StyleProvider.js 10:19
Module parse failed: Unexpected token (10:19)
You may need an appropriate loader to handle this file type.
| */
| export default class StyleProvider extends React.Component {
> static propTypes = {
| children: PropTypes.element.isRequired,
| style: PropTypes.object,
# ./node_modules/native-base-shoutem-theme/index.js 3:0-48 7:0-15:2
# ./node_modules/native-base/dist/src/index.js
# ./screens/Academics/HomeWorkScreen.js
# ./App.js
# ./index.js
# multi ./node_modules/haul/src/vendor/polyfills/Object.es6.js ./node_modules/haul/src/vendor/polyfills/console.js ./node_modules/haul/src/vendor/polyfills/error-guard.js ./node_modules/haul/src/vendor/polyfills/Number.es6.js ./node_modules/haul/src/vendor/polyfills/String.prototype.es6.js ./node_modules/haul/src/vendor/polyfills/Array.prototype.es6.js ./node_modules/haul/src/vendor/polyfills/Array.es6.js ./node_modules/haul/src/vendor/polyfills/Object.es7.js ./node_modules/haul/src/vendor/polyfills/babelHelpers.js ./node_modules/react-native/Libraries/Core/InitializeCore.js ./node_modules/haul/src/utils/polyfillEnvironment.js ./index.js
./node_modules/native-base-shoutem-theme/src/connectStyle.js 116:26
Module parse failed: Unexpected token (116:26)
You may need an appropriate loader to handle this file type.
|
| class StyledComponent extends React.Component {
> static contextTypes = {
| theme: ThemeShape,
| // The style inherited from the parent
# ./node_modules/native-base-shoutem-theme/index.js 1:0-46 7:0-15:2
# ./node_modules/native-base/dist/src/index.js
# ./screens/Academics/HomeWorkScreen.js
# ./App.js
# ./index.js
# multi ./node_modules/haul/src/vendor/polyfills/Object.es6.js ./node_modules/haul/src/vendor/polyfills/console.js ./node_modules/haul/src/vendor/polyfills/error-guard.js ./node_modules/haul/src/vendor/polyfills/Number.es6.js ./node_modules/haul/src/vendor/polyfills/String.prototype.es6.js ./node_modules/haul/src/vendor/polyfills/Array.prototype.es6.js ./node_modules/haul/src/vendor/polyfills/Array.es6.js ./node_modules/haul/src/vendor/polyfills/Object.es7.js ./node_modules/haul/src/vendor/polyfills/babelHelpers.js ./node_modules/react-native/Libraries/Core/InitializeCore.js ./node_modules/haul/src/utils/polyfillEnvironment.js ./index.js
./node_modules/rn-fetch-blob/index.js 13:12
Module parse failed: Unexpected token (13:12)
You may need an appropriate loader to handle this file type.
| AppState,
| } from 'react-native'
> import type {
| RNFetchBlobNative,
| RNFetchBlobConfig,
# ./screens/Academics/HomeWorkScreen.js 1:603-627
# ./App.js
# ./index.js
# multi ./node_modules/haul/src/vendor/polyfills/Object.es6.js ./node_modules/haul/src/vendor/polyfills/console.js ./node_modules/haul/src/vendor/polyfills/error-guard.js ./node_modules/haul/src/vendor/polyfills/Number.es6.js ./node_modules/haul/src/vendor/polyfills/String.prototype.es6.js ./node_modules/haul/src/vendor/polyfills/Array.prototype.es6.js ./node_modules/haul/src/vendor/polyfills/Array.es6.js ./node_modules/haul/src/vendor/polyfills/Object.es7.js ./node_modules/haul/src/vendor/polyfills/babelHelpers.js ./node_modules/react-native/Libraries/Core/InitializeCore.js ./node_modules/haul/src/utils/polyfillEnvironment.js ./index.js
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleDemshReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Your problem is that somehow or other, babel is not configured correctly to compile the features that exist in the code mentioned in those errors.
The specific problems:
static method properties (you need https://babeljs.io/docs/en/babel-plugin-proposal-class-properties)
flow types (you need https://babeljs.io/docs/en/babel-plugin-transform-flow-strip-types)
It's hard to say exactly what is wrong with your config, but a faster way to test is to run the babel CLI directly on those files. If you ensure that BABEL_ENV and any other babel cli/env/API flags are set the same way as they are in the webpack build (you might have to do some debugging to find where babel-loader is applied), you can do for example yarn run babel node_modules/native-base-shoutem-theme/src/StyleProvider.js
If you can reproduce the problem like this, you can experiment in a much tigher loop with your babel configuration until you find a solution.
A good starting points is updating babel and all the presets/plugins you have installed.

Scala 2.11 refined with scalatest MustMatchers and Await causes compiler error "trying to do lub/glb of typevar ?F[?T, ?B]"

I have been trying to use the refined with scalatest and am getting compiler errors at the "typer" phase: trying to do lub/glb of typevar ?F[?T, ?B]
This is my best attempt at a minimalist reproduction of the issue using a self-contained ammonite script:
import $ivy.`eu.timepit::refined:0.9.0`
import $ivy.`org.scalatestplus.play::scalatestplus-play:3.1.2`
import org.scalatest.{MustMatchers, WordSpec}
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import eu.timepit.refined.auto.autoInfer
class RefinedSpec extends WordSpec with MustMatchers {
val duration = 500.millis
val fut = Future.successful("123")
Await.result(fut, atMost = duration)
}
If you make any one of the following changes to the above it will successfully compile:
delete: import eu.timepit.refined.auto.autoInfer
remove: with MustMatchers from the class definition
delete: Await.result(fut, atMost = duration)
To clarify, this is a compilation error, not a runtime error. The original error is happening in a play app (scala 2.11.11) whilst running test:compile in sbt, but it's probably easier to reproduce it with the ammonite script.
The ammonite version I'm using gives version info:
Welcome to the Ammonite Repl 1.1.2
(Scala 2.11.12 Java 1.8.0_25)
Installed using:
sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/Ammonite/releases/download/1.1.2/2.11-1.1.2) > /usr/local/bin/amm && chmod +x /usr/local/bin/amm' && amm
More error details from the ammonite example:
scala.reflect.internal.FatalError:
trying to do lub/glb of typevar ?F[?T, ?B]
while compiling: fail.sc
during phase: typer
library version: version 2.11.12
compiler version: version 2.11.12
reconstructed args: -nowarn -Yresolve-term-conflict:object
last tree to typer: Ident(<argument>)
tree position: line 15 of fail.sc
tree tpe: String
symbol: <none>
symbol definition: <none> (a NoSymbol)
symbol package: <none>
symbol owners:
call site: class RefinedSpec in object fail in package $file
From play sbt test:compile I also get this kind of output:
[error] last tree to typer: Ident(<argument>)
[error] tree position: line 13 of ...../RefinedSpec.scala
[error] tree tpe: String
[error] symbol: <none>
[error] symbol definition: <none> (a NoSymbol)
[error] symbol package: <none>
[error] symbol owners:
[error] call site: class RefinedSpec in package foo in package foo
[error]
[error] == Source file context for tree position ==
[error]
[error] 10 val duration = 500.millis
[error] 11 val fut = Future.successful("123")
[error] 12 Await.result(fut, atMost = duration)
[error] 13 }
This isn't a serious issue as I can just remove the autoInfer import as I'm not actually using it. It will trip people up though because they'll tend to do:
import eu.timepit.refined.auto._
to get automatic conversion from compile-time constants into refined types, when they can probably just get away with:
import eu.timepit.refined.auto.autoRefineV

How to configure este to work with react-toolbox?

As recomended in este wiki, I would like to use react-toolbox to create components in material design. I have installed react-toolbox with npm. I got this error while trying to use button.
ERROR in ./~/css-loader!./~/postcss-loader!./~/react-toolbox/lib/button/theme.css
Module build failed: Error: No PostCSS Config found in: /home/alenka/Documents/bakalárka/esteDir/este/node_modules/react-toolbox/lib/button
at Error (native)
at /home/alenka/Documents/bakalárka/esteDir/este/node_modules/postcss-load-config/index.js:51:26
# ./~/react-toolbox/lib/button/theme.css 4:14-100 13:2-17:4 14:20-106
# ./~/react-toolbox/lib/button/index.js
# ./src/browser/home/HomePage.js
# ./src/browser/app/routeConfig.js
# ./src/browser/app/Root.js
# ./src/browser/main.js
# ./src/browser/index.js
# multi webpack-hot-middleware/client?path=http://192.168.1.41:8080/__webpack_hmr ./src/browser/index.js
ERROR in ./~/css-loader!./~/postcss-loader!./~/react-toolbox/lib/ripple/theme.css
Module build failed: Error: No PostCSS Config found in: /home/alenka/Documents/bakalárka/esteDir/este/node_modules/react-toolbox/lib/ripple
at Error (native)
at /home/alenka/Documents/bakalárka/esteDir/este/node_modules/postcss-load-config/index.js:51:26
# ./~/react-toolbox/lib/ripple/theme.css 4:14-100 13:2-17:4 14:20-106
# ./~/react-toolbox/lib/ripple/index.js
# ./~/react-toolbox/lib/button/index.js
# ./src/browser/home/HomePage.js
# ./src/browser/app/routeConfig.js
# ./src/browser/app/Root.js
# ./src/browser/main.js
# ./src/browser/index.js
# multi webpack-hot-middleware/client?path=http://192.168.1.41:8080/__webpack_hmr ./src/browser/index.js
Could anybody help me please?

SBT: Unable to resolved dependencies for date range picker

I am trying to use this React based date range picker in my Play 2.5/Scala application:
https://github.com/onefinestay/react-daterange-picker
However, one of the dependencies cannot be found:
[warn] :: org.webjars.npm#calendar;0.2.1: not found
[warn] :: org.webjars.npm#calendar;[0.1.0,0.2): not found
...
[error] (common/*:update) sbt.ResolveException: unresolved dependency: org.webjars.npm#calendar;0.2.1: not found
[error] unresolved dependency: org.webjars.npm#calendar;[0.1.0,0.2): not found
There is no such package as "calendar" in webjars.org repository. Has the name changed? Any idea how I can make this datepicker build successfully ?
I found react-datepicker and react-bootstrap-daterangepicker.
libraryDependencies += "org.webjars.npm" % "react-datepicker" % "0.12.0"
or
libraryDependencies += "org.webjars.npm" % "react-bootstrap-daterangepicker" % "1.0.4"

How do i do a production build on AngularCLI rc.1?

I just updated to angular-cli 1.0.0-rc1 after following the upgrade instructions on the wiki.
When i run ng serve - the app behaves correctly.
When i run ng build - the app behaves correctly.
When I run ng build --target=production --environment=prod
I get the following:
➜ web git:(master) ✗ ng build --target=production --environment=prod
Hash: 1e69750dbc9679bddab0
Time: 69052ms
chunk {0} main.8839163bd6c77300ac2a.bundle.js (main) 1.11 MB {3} [initial] [rendered]
chunk {1} styles.014a26b5c21b6bdedf9e.bundle.css (styles) 440 bytes {4} [initial] [rendered]
chunk {2} scripts.73c5e350c283a9340ddc.bundle.js (scripts) 146 kB {4} [initial] [rendered]
chunk {3} vendor.f208e8b0304d6a96ac3d.bundle.js (vendor) 2.54 MB [initial] [rendered]
chunk {4} inline.1eab99acff53ba884df2.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in ../api/src/business/dtos/modifier.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:139:44)
at Array.filter (native)
at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:138:14)
at Array.forEach (native)
at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:129:10)
at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:292:33)
# ./src/app/model-labels/model-label.component.ts 3:0-51
# ./src/$$_gendir/app/app.module.ngfactory.ts
# ./src/main.ts
# multi ./src/main.ts
ERROR in ../api/src/business/dtos/document.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:139:44)
at Array.filter (native)
at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:138:14)
at Array.forEach (native)
at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:129:10)
at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:292:33)
# ./src/app/document-viewer/document-viewer.component.ts 2:0-51
# ./src/$$_gendir/app/app.module.ngfactory.ts
# ./src/main.ts
# multi ./src/main.ts
ERROR in ../api/src/business/dtos/models.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:139:44)
at Array.filter (native)
at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:138:14)
at Array.forEach (native)
at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:129:10)
at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:292:33)
# ./src/app/model-sublabel/model-sublabel.component.ts 1:0-46
# ./src/$$_gendir/app/app.module.ngfactory.ts
# ./src/main.ts
# multi ./src/main.ts
ERROR in ../api/src/business/dtos/lens.dto.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
at Object.getTokenPosOfNode (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:6768:71)
at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80500:23)
at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jmurphy/projects/business/web/node_modules/typescript/lib/typescript.js:80521:77)
at refactor.findAstNodes.filter (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:139:44)
at Array.filter (native)
at refactor.findAstNodes.forEach.node (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:138:14)
at Array.forEach (native)
at _removeDecorators (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:129:10)
at Promise.resolve.then (/Users/jmurphy/projects/business/web/node_modules/#ngtools/webpack/src/loader.js:292:33)
# ./src/app/create-lens/create-lens.component.ts 2:0-43
# ./src/$$_gendir/app/app.module.ngfactory.ts
# ./src/main.ts
# multi ./src/main.ts
ERROR in main.8839163bd6c77300ac2a.bundle.js from UglifyJs
Unexpected token: name (FooterComponent) [main.8839163bd6c77300ac2a.bundle.js:7,6]
How do i get my app to compile correctly for production?
UPDATE 1:
Here's an example of one of the offending files. ColumnTypes.TEXT is a public value. As these are just decorators, they have no external dependencies. Again, this works fine for non production builds.
import {autoserialize} from "cerialize";
import {ManyToOne, PrimaryGeneratedColumn, Column, JoinColumn, OneToOne, OneToMany, Table, ColumnTypes, CreateDateColumn} from "./export.dtos";
#Table()
export class DTOModifier {
#PrimaryGeneratedColumn()
#autoserialize id: number;
#Column(ColumnTypes.TEXT, {nullable: true})
#autoserialize label: string;
}
Where:
static TEXT: ColumnType;
When doing a production build with angluar-cli > beta.27 (i think it was beta 27), you are implicitly using ahead-of-time compilation.
Ahead-of-Time-compilation only works, when the component-members you access from your templates are public. It seems that you have a component with some classmember text that is set to private.
The reason for this is, that ngc (the angular compiler) will make a regular typescript-class out of your template, and when trying to compile this file, the temporary template-class has no access to private component-members.
edit:
I'm not 100% sure that this is actually your problem, but this is a problem i faced when i started making production builds, and you could have the same problem because the errors look similar

Resources