NG8001: 'mat-table' is not a known element: - angular-material

I am trying to adapt the following
Example
which works fine. But in my Angular 11 application I ma getting:
error NG8001: 'mat-table' is not a known element
I am using the exact same code that I have placed inside of the shared module. In the shared module I have added the following:
import { MatTableModule } from '#angular/material/table';
#NgModule({
imports: [
MatTableModule
],
...
exports: [
MatTableModule
]
Still, it's not working. Any adea?
Thanks

Related

Dependency exports an empty object when bundling component library with Rollup

I'm trying to use rollup to build my React component library. The bundle step completes with a few warnings, however, when I actually try to use it in a Next.js application, I get many "X is not a function" errors when visiting the website. It seems to happen because some dependencies inside the _virtual directory are empty:
For example, this is dist/_virtual/d3-time-format.js (my library uses #visx/scale, which depends on d3-scale, which in turn depends on d3-time-format)
var d3TimeFormat = {exports: {}};
export { d3TimeFormat as d };
//# sourceMappingURL=d3-time-format.js.map
As you can see above, the exports is an empty object, so I get the error "format is not a function". This happens also with other modules, like prop-types (my dependencies depend on it).
This is my rollup.config.js:
import { babel } from '#rollup/plugin-babel';
import commonjs from '#rollup/plugin-commonjs';
import resolve from '#rollup/plugin-node-resolve';
import typescript from '#rollup/plugin-typescript';
import svgr from '#svgr/rollup';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
function bundle(inputPath) {
return {
input: inputPath,
output: [
{
dir: `./dist`,
format: 'esm',
sourcemap: true,
preserveModules: true,
preserveModulesRoot: 'src',
},
],
plugins: [
peerDepsExternal(),
commonjs(),
resolve(),
svgr({
icon: true,
replaceAttrValues: { '#000': '{props.color}' },
svgProps: { fill: 'currentColor' },
}),
typescript(),
babel({
babelHelpers: 'runtime',
exclude: /node_modules/,
extensions: ['.js', '.ts', '.tsx'],
}),
],
};
}
export default [bundle('./src/index.ts')];
When bundling I get these warnings, not sure if they are relevant:
Would appreciate some guidance on what the files inside _virtual are and why they are generated with an empty object. Thanks#

Is there a rule representing an ECMAScript library in Bazel rules_nodejs?

Most of my code is represented by ECMA Script libraries that have import and export rather than require statements.
Is there a suggested way to represent such libraries using rules_dotnet?
I am looking for something like this:
load("#build_bazel_rules_nodejs//:index.bzl", "ecmascript_library")
ecmascript_library(
name = "foo",
srcs = [
"foo.js"
],
)
ecmascript_library(
name = "bar",
srcs = [
"bar.js"
],
deps = [
":foo",
],
)
Where Bazel will ensure the search paths for rules consuming bar can find foo.
I would then like to use my library definitions to create bundles for Node.js etc.
How can I accomplish this?

Unable to create an AWS managed Active directory with AWS-CDK using python

I am trying to create a managed AD with AWS-CDK using python. Following is the error, raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Value did not match any type in union: Missing required properties for #aws-cdk/aws-directoryservice.CfnMicrosoftAD.VpcSettingsProperty: subnetIds, vpcId, Expected object reference, got {"$jsii.map":{"subnet_ids":["subnet-12345678","subnet-12345678"],"vpc_id":"vpc-12345678"}}.Below is the code from the main stack. PS : I am new to AWS-CDK.
from aws_cdk import core as cdk
from aws_cdk import aws_s3
from aws_cdk import aws_directoryservice as ad
from aws_cdk import core
from aws_cdk import aws_ec2 as ec2
class ManagedADStack (core.Stack):
def __init__(self, scope: cdk.Construct, construct_id: str,
**kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
AD = ad.CfnMicrosoftAD(self ,
name= "corp.example.com",
id= "d1234",
password= "randompass",
vpc_settings= {
"subnet_ids": [ "subnet-123456789" , "subnet-987654321" ],
"vpc_id": "vpc-12345678"
}
)
Hi Kartheek and welcome to AWS-CDK.
You can use the VpcSettingsProperty as a class:
AD = ad.CfnMicrosoftAD(self ,
name= "corp.example.com",
id= "d1234",
password= "randompass",
vpc_settings= ad.CfnMicrosoftAD.VpcSettingsProperty (
subnet_ids= [ "subnet-123456789" , "subnet-987654321" ],
vpc_id= "vpc-12345678"
)
)

How do I register component globally in Quasar?

I have a component which I'll be using in every page of my web-app. To simplify my work how do I register this component globally? I used nuxt once and it was so easy by npm #nuxtjs/global-components. What is process with Quasar? Thank you!
You can create a boot file with all your global components, e.g. global-components.js
There you need to import your components and apply them to Vue:
import Vue from 'vue'
import MyComponent from '../component/MyComponent.vue'
Vue.component('my-component', MyComponent)
Lastly you need to call your boot file in quasar.conf.js
boot: ["global-components"]
More info
In Quasar 2:
import { boot } from 'quasar/wrappers'
import MyComponent from '../components/MyComponent.vue'
export default boot(async ({ app }) => {
app.component('my-component', MyComponent)
})
I use this solution and it helps us to dynamically register component
Create a file in src/boot folder for example i created register-my-component.js and white this code:
// src/boot/register-my-component.js
import upperFirst from "lodash/upperFirst";
import camelCase from "lodash/camelCase";
export default ({ app }) => {
const requireComponent = require.context(
"src/components",
true,
/[A-Z-_]\w+\.(vue)$/
);
requireComponent.keys().forEach((fileName) => {
const componentConfig = requireComponent(fileName);
const componentName = upperFirst(
camelCase(
fileName
.split("/")
.pop()
.replace(/\.\w+$/, "")
)
);
app.component(componentName, componentConfig.default || componentConfig);
});
};
Now register this boot file in quasar.conf.js. you can find it in the root directory
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/boot-files
boot: [ ..., "register-my-component" ],
Now you don't need to import and register components anymore (NOTE: as you can see only components in src/component register automatically. So if you write your component in other paths you need to import and register that)

CDK generating empty targets for CfnCrawler

I'm using CDK Python API to define a Glue crawler, however, the CDK generated template contains empty 'Targets' block in the Crawler resource.
I've not been able to find an example to emulate. I've tried varying the definition of the targets object, but the object definition seems to be ignored by CDK.
from aws_cdk import cdk
BUCKET='poc-1-bucket43879c71-5uabw2rni0cp'
class PocStack(cdk.Stack):
def __init__(self, app: cdk.App, id: str, **kwargs) -> None:
super().__init__(app, id)
from aws_cdk import (
aws_iam as iam,
aws_glue as glue,
cdk
)
glue_role = iam.Role(
self, 'glue_role',
assumed_by=iam.ServicePrincipal('glue.amazonaws.com'),
managed_policy_arns=['arn:aws:iam::aws:policy/service-role/AWSGlueServiceRole']
)
glue_crawler = glue.CfnCrawler(
self, 'glue_crawler',
database_name='db',
role=glue_role.role_arn,
targets={"S3Targets": [{"Path": f'{BUCKET}/path/'}]},
)
I expect the generated template to contain a valid 'targets' block with a single S3Target. However, cdk synth outputs a template with empty Targets in the AWS::Glue::Crawler resource:
gluecrawler:
Type: AWS::Glue::Crawler
Properties:
DatabaseName: db
Role:
Fn::GetAtt:
- glueroleFCCAEB57
- Arn
Targets: {}
Resolved, thanks to a clever colleague!
Changing "S3Targets" to "s3Targets", and "Path" to "path" resolved the issue. See below.
Hi Bob,
When I use typescript, the following works for me:
new glue.CfnCrawler(this, 'glue_crawler', {
databaseName: 'db',
role: glue_role.roleArn,
targets: {
s3Targets: [{ path: "path" }]
}
}
When I used Python, the following appears working too:
glue_crawler = glue.CfnCrawler(
self, 'glue_crawler',
database_name='db',
role=glue_role.role_arn,
targets={
"s3Targets": [{ "path": f'{BUCKET}/path/'}]
},
)
In Typescript, TargetsProperty is an interface with s3Targets as a property. And in
s3Targets, path is a property as well. I guess during the JSII transformation, it forces
us to use the same names in Python instead of the initial CFN resource names.
A more general way to approach this problem is to dig inside the cdk library in 2 steps:
1.
from aws_cdk import aws_glue
print(aws_glue.__file__)
(.env/lib/python3.8/site-packages/aws_cdk/aws_glue/__init__.py)
Go to that file and see how the mapping/types are defined. As of 16 Aug 2020, you find
#jsii.data_type(
jsii_type="#aws-cdk/aws-glue.CfnCrawler.TargetsProperty",
jsii_struct_bases=[],
name_mapping={
"catalog_targets": "catalogTargets",
"dynamo_db_targets": "dynamoDbTargets",
"jdbc_targets": "jdbcTargets",
"s3_targets": "s3Targets",
}
)
I found that the lowerCamelCase always work, while the pythonic snake_case does not.

Resources