You may need an appropriate loader to handle this file - .net core & Angular - node.js

I keep getting the following error web running a production build of a .net core angular 4 application. Those are 2 node packages I installed and looks like their is some issue with webpack reading those files only for production builds. Any thoughts?
ERROR in ./$$_gendir/~/ngx-mydatepicker/dist/ngx-my-date-picker.component.ngfactory.ts
Module parse failed: d:\a\1\s\Vacant2\$$_gendir\node_modules\ngx-mydatepicker\dist\ngx-my-date-picker.component.ngfactory.ts Unexpected token (14:28)
You may need an appropriate loader to handle this file type.
| import * as i3 from 'ngx-mydatepicker/dist/directives/ngx-my-date-picker.focus.directive';
| import * as i4 from 'ngx-mydatepicker/dist/services/ngx-my-date-picker.util.service';
| const styles_NgxMyDatePicker:any[] = ['.ngxmdp .headertodaybtn,.ngxmdp .monthcell,.ngxmdp .weekdaytitle{overflow:hidden;white-space:nowrap}.ngxmdp *{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:Arial,Helvetica,sans-serif;padding:0;margin:0}.ngxmdp .selector{position:absolute;padding:0;border:1px solid #CCC;border-radius:4px;z-index:100000;animation:selectorfadein 60ms}.ngxmdp .selector:focus{border:1px solid #ADD8E6;outline:0}#keyframes selectorfadein{from{opacity:0}to{opacity:1}}.ngxmdp .selectorarrow{background:#FAFAFA;padding:0}.ngxmdp .selectorarrow:after,.ngxmdp .selectorarrow:before{bottom:100%;border:solid transparent;content:" ";height:0;width:0;position:absolute}.ngxmdp .selectorarrow:after{border-color:rgba(250,250,250,0);border-bottom-color:#FAFAFA;border-width:10px;margin-left:-10px}.ngxmdp .selectorarrow:before{border-color:rgba(204,204,204,0);border-bottom-color:#CCC;border-width:11px;margin-left:-11px}.ngxmdp .selectorarrow:focus:before{bord...
| export const RenderType_NgxMyDatePicker:i0.RendererType2 = i0.ɵcrt({encapsulation:2,
| styles:styles_NgxMyDatePicker,data:{}});
# ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts 10:0-115
# ./ClientApp/boot.server.ts
ERROR in ./$$_gendir/~/ngx-loading/ngx-loading.ngfactory.ts
Module parse failed: d:\a\1\s\Vacant2\$$_gendir\node_modules\ngx-loading\ngx-loading.ngfactory.ts Unexpected token (12:35)
You may need an appropriate loader to handle this file type.
| import * as i1 from 'ngx-loading';
| import * as i2 from '#angular/common';
| export const LoadingModuleNgFactory:i0.NgModuleFactory<i1.LoadingModule> = i0.ɵcmf(i1.LoadingModule,
| ([] as any[]),(_l:any) => {
| return i0.ɵmod([i0.ɵmpd(512,i0.ComponentFactoryResolver,i0.ɵCodegenComponentFactoryResolver,
# ./$$_gendir/ClientApp/app/components/app/app.component.ngfactory.ts 9:0-94
# ./$$_gendir/ClientApp/app/app.module.server.ngfactory.ts
# ./ClientApp/boot.server.ts

I found the solution here https://github.com/aspnet/JavaScriptServices/issues/1168#issuecomment-320026397
Just needed to remove include: /ClientApp/ from myh webpack.config.js.

Related

ReferenceError: json2html is not defined in jest test using ts-jest

I am trying to use node-jsdom2html module from within jest test, but I am getting this error:
ReferenceError: json2html is not defined
1 | import generateReport from "../report-generator";
> 2 | import * as jsontohtml from '../../node_modules/node-json2html/node.json2html'
| ^
3 | import {
4 | fullConfig,
5 | fullResult,
at Object.<anonymous> (node_modules/node-json2html/node.json2html.js:18:18)
at Object.<anonymous> (src/__tests__/index.spec.ts:2:1)
I did a demo repository with the code I am trying to execute and I am facing the error:
https://github.com/cunhabruno/jest-bug-node-json2html/blob/main/__tests__/demo.spec.ts

How to install npm packages in BigQuery?

I unfortunately can not any reliable documentation on how to use an npm package in BigQuery. I want to use the package isitblocked in BigQuery and parse the URLs in my tables through the library.
I only found this blog, but I can't re-procedure the steps there and get the following error while using webpack:
`assets by status 390 bytes [cached] 1 asset
./index.ts 2.43 KiB [built] [code generated] [1 error]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to > 'production' for this value.
Set 'mode' option to 'development' or 'production' to enable > defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in ./index.ts 1:16
Module parse failed: Unexpected token (1:16)
You may need an appropriate loader to handle this file type, > currently no loaders are configured to process this file. See > > https://webpack.js.org/concepts#loaders
import envPaths = require("env-paths");
| import Listr = require("listr");
| import fs = require("fs-extra");
\
The package I try to install is isitblocked.
I did it step by step in the google Shell and it prompted to install the webpack. Please include the mode none or production
npx webpack --config webpack.config.js --mode none
Then upload the file under dist and edit the BigQuery query to:
CREATE TEMP FUNCTION get_rand_card_number()
RETURNS STRING
LANGUAGE js
OPTIONS (
library=["gs://***your*bucket*name***/creditcard-generator.js"]
)
AS r"""
return webpackNumbers.GenCC("Amex"); # Still wrong function name
""";
CREATE TEMP FUNCTION get_rand_id()
RETURNS STRING
LANGUAGE js
AS r"""
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 4 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(4);
});
""";
SELECT
x,
get_rand_id() as unique_id,
get_rand_card_number() as credit_card_number
FROM
unnest(generate_array(1,100,1)) x

#quasar/extras/mdi-v4 jest unit testing failing on Unexpected token 'export'

I am using the new SVG images. I have created a test for a header that contains a logo, name mdiMenu.
import { mdiMenu } from '#quasar/extras/mdi-v4'
But everything I am running the test: I always get this error:
SyntaxError: Unexpected token 'export'
29 |
30 | <script>
> 31 | import { mdiMenu } from '#quasar/extras/mdi-v4'
Do somebody else have encounter this problem and how can I solve this?
This is the rest of the error message:
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
C:\Users\YohnCheung\work\bitBucket\central-station\node_modules\#quasar\extras\mdi-v4\index.js:3
export const mdiAbTesting = 'M4 2A2 2 0 0 0 2 4V12H4V8H6V12H8V4A2 2 0 0 0 6 2H4M4 4H6V6H4M22 15.5V14A2 2 0 0 0 20 12H16V22H20A2 2 0 0 0 22 20V18.5A1.54 1.54 0 0 0 20.5 17A1.54 1.54 0 0 0 22 15.5M20 20H18V18H20V20M20 16H18V14H20M5.79 21.61L4.21 20.39L18.21 2.39L19.79 3.61Z'
^^^^^^
Question was taken from:
https://forum.quasar-framework.org/topic/5459/quasar-extras-mdi-v4-jest-unit-testing-failing
https://forum.vuejs.org/t/quasar-extras-mdi-v4-jest-unit-testing-failing/89973
Correct transformation need to be set.
So you need to configure jest.config.js correctly
...
transform: {
'^.+\\.jsx?$': require.resolve('babel-jest'),
},
...
My jest config is extending preset
preset: '#vue/cli-plugin-unit-jest/presets/typescript-and-babel',
which already includes this transform, but also sets not to transform pacages from node_modules
transformIgnorePatterns: ['/node_modules/'],
reference: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-unit-jest/presets/default/jest-preset.js
therefore in my config I have changed pattern to
transformIgnorePatterns: ['node_modules/(?!(quasar|quasar/*|#quasar|#quasar/*))'],
so it ignores all packages but quasar's
Hope this answer will help someone :)

Compiling Rocket in Bazel

I'm attempting to get a working prototype of the following scenario:
Language: Rust (rustc 1.45.0-nightly (ad4bc3323 2020-06-01))
Framework: Rocket v0.4.4
Build Tool: Bazel
Platform: Mac OS X / Darwin x64
Running bazel build //web-api yields the below error. I believe, based on looking at the Cargo.lock file it is because Rocket's dependency on the hyper library specifies a dependency on the log 0.3.9 library. For whatever reason it is not using the more recent log=0.4.x. That said, I don't know why it's pulling this library since, if I build it manually, it works fine.
ERROR: /private/var/tmp/_bazel_nathanielford/2a39169ea9f6eb02fe788b12f9eae88f/external/raze__log__0_3_9/BUILD.bazel:27:1: error executing shell command: '/bin/bash -c CARGO_MANIFEST_DIR=$(pwd)/external/raze__log__0_3_9 external/rust_darwin_x86_64/bin/rustc "$#" --remap-path-prefix="$(pwd)"=__bazel_redacted_pwd external/raze__log__0_3_9/src/lib.rs -...' failed (Exit 1) bash failed: error executing command /bin/bash -c 'CARGO_MANIFEST_DIR=$(pwd)/external/raze__log__0_3_9 external/rust_darwin_x86_64/bin/rustc "$#" --remap-path-prefix="$(pwd)"=__bazel_redacted_pwd' '' external/raze__log__0_3_9/src/lib.rs ... (remaining 24 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
error[E0425]: cannot find function `set_logger` in crate `log`
--> external/raze__log__0_3_9/src/lib.rs:731:16
|
731 | match log::set_logger(&ADAPTOR) {
| ^^^^^^^^^^ not found in `log`
|
help: consider importing this function
|
204 | use set_logger;
|
The following is my directory structure:
/
|-WORKSPACE
|-BUILD # Empty
|-web-api/
| |-BUILD
| |-src/
| | |-main.rs
| |-cargo/
| |-Cargo.toml
| |-Cargo.lock
| |-BUILD.bazel
| |-remote/
| |-... (Cargo-raze files)
In order to set up the cargo-raze I did the following, following instructions from the github page.:
$ cd web-api/cargo
$ cargo generate-lockfile
$ cargo vendor --versioned-dirs --locked
$ cargo raze
(The generate-lockfile is what creates the Cargo.lock file, and the cargo raze is what creates the BUILD.bazel file and all the contents of the remote sub directory.)
And then to execute the bazel build I go back to the root and run bazel build //web-api, which produces the above error.
This is my WORKSPACE file:
workspace(name = "rocket-bazel")
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_rust",
sha256 = "f21c67fc2fef9d57fa3c81fde1defd9e57d451883388c0a469ec1c470fd30dcb",
strip_prefix = "rules_rust-master",
urls = [
"https://github.com/bazelbuild/rules_rust/archive/master.tar.gz"
],
)
http_archive(
name = "bazel_skylib",
sha256 = "9a737999532daca978a158f94e77e9af6a6a169709c0cee274f0a4c3359519bd",
strip_prefix = "bazel-skylib-1.0.0",
url = "https://github.com/bazelbuild/bazel-skylib/archive/1.0.0.tar.gz",
)
load("#io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")
rust_repositories(version="nightly", iso_date="2020-06-02")
load("#io_bazel_rules_rust//:workspace.bzl", "bazel_version")
bazel_version(name = "bazel_version")
load("//web-api/cargo:crates.bzl", "raze_fetch_remote_crates")
raze_fetch_remote_crates()
This is my web-api/BUILD file:
load("#io_bazel_rules_rust//rust:rust.bzl", "rust_binary")
rust_binary(
name = "web-api",
srcs = ["src/main.rs"],
deps = [
"//web-api/cargo:rocket",
],
)
And my web-api/cargo/Cargo.toml file:
load("#io_bazel_rules_rust//rust:rust.bzl", "rust_binary")
rust_binary(
name = "web-api",
srcs = ["src/main.rs"],
deps = [
"//web-api/cargo:rocket",
],
)
I've run out of ideas as to what to try. I can get this to compile without Bazel, just using rust (though obviously the files are in slightly different places). I can get it to compile inside a Docker container. I just can't get Bazel (necessarily with cargo raze, either in vendor or remote mode) to run successfully: I assume that there is some mismatch in compile target or the nightly build that is not being properly set - but I'm not sure how to diagnose or get past that.
Here is a link to a repository with the files/structure I tried.
I had a similar issue when I made a minimal Bazel workspace with rust and the log crate together with env_logger crate. I found a similar issue when you try to compile without features = ["std"]. I then tried to enable that in Cargo.toml on the log dependency without success.
My solution is that in Cargo.toml under [raze] I added:
default_gen_buildrs = true
I could trace it down to that when default_gen_buildrs flag is not set in the generated log crate the BUILD.bazel file did not have a cargo_build_script definition or this:
crate_features = [
"std",
],

Can't import .lhs script in Haskell

I have two files, S5.hs and S6.lhs, in the same folder, and I want to import the S6.lhs script in S5.hs, but when i type import S6, i get:
Could not find module `S6'
Use -v to see a list of the files searched for.
|
1 | import S6
| ^^^^^^^^^^
Failed, no modules loaded.
When I lauch it from the folder, I get following message(the first line of the S6 file is import Data.Array):
File name does not match module name:
Saw: `Main'
Expected: `S6'
|
1 | import Data.List
| ^
Why is this happening?
Looks like you need to specify at the top of the S6.lhs file that you want this file to be treated as the S6 module, as opposed to the default module name of Main. You would do that with module S6 where or module S6 (export, list) where.

Resources