-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to Angular 6 #30
Conversation
The latest commit uses the angular cli to build the library. |
"deleteDestPath": false, | ||
"lib": { | ||
"entryFile": "src/public_api.ts", | ||
"styleIncludePaths": ["./src/scss"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to build the styles with the cli, but the styles didn't get picked up.
Any ideas? Or do we keep it as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check out the PR later on my local machine and see if I find something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also add "styleIncludePaths": ["./src/scss"]
to ng-package-prod.json
(?) file because we're building it with the prod
flag.
{ | ||
"extends": "../../tslint.json", | ||
"rules": { | ||
"directive-selector": [false, "attribute", "ngx", "camelCase"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rule is disabled for now.
When we rename selectItem
to something more suitable, we'll have to turn this back on.
src/app/app.module.ts
Outdated
@@ -29,6 +28,7 @@ import { FooterComponent } from './footer/footer.component'; | |||
import { HeaderComponent } from './header/header.component'; | |||
import { PhoneComponent } from './phone/phone.component'; | |||
import { LayoutModule } from '@angular/cdk/layout'; | |||
import { DragToSelectModule } from '../../projects/ngx-drag-to-select/src/lib/drag-to-select.module'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to import from ngx-drag-to-select
here?
If so I think we'll have to modify the build process I think.
package.json
Outdated
"build:server": "ng build --prod --project=server", | ||
"build:lib": "npm run clean && npm run build:lib:code && npm run build:lib:sass && npm run copy:styles && npm run copy:readme", | ||
"build:lib:code": "ng build --prod --project=ngx-drag-to-select", | ||
"build:lib:sass": "node-sass projects/ngx-drag-to-select/src/scss/ngx-drag-to-select.scss -o dist/ngx-drag-to-select", | ||
"deploy": "ngh --dir dist/browser", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used @d3lm ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only meant to be used locally, if needed.
f00e570
to
fa8725b
Compare
const mousePosition = getRelativeMousePosition(event, container); | ||
// Explicit cast to `MousePosition` in order to "use" `MousePosition` | ||
// we have to import `MousePosition` otherwise we'll get a build error | ||
const mousePosition: MousePosition = getRelativeMousePosition(event, container); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you got a better solution?
The build was throwing an error because it didn't know MousePosition
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this doesn't work if we add the return type to getRelativeMousePosition
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try it out later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick check and it doesn't work.
I added a return type to getMousePosition
because getRelativeMousePosition
already has a return type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I remove the type annotation and run either yarn start
or build the app for prod with yarn build
everything works for me. Can you try again? What is the error? Is TS complaining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error comes when you try to build the lib build:lib
.
BUILD ERROR
projects/ngx-drag-to-select/src/lib/operators.ts(6,14): error TS4023: Exported variable 'createSelectBox' has or is using name 'MousePosition' from external module "C:/Users/tdeschryver/dev/ngx-drag-to-select/projects/ngx-drag-to-select/src/lib/models" but cannot be named.
Error: projects/ngx-drag-to-select/src/lib/operators.ts(6,14): error TS4023: Exported variable 'createSelectBox' has or is using name 'MousePosition' from external module "C:/Users/tdeschryver/dev/ngx-drag-to-select/projects/ngx-drag-to-select/src/lib/models" but cannot be named.
at Object.<anonymous> (C:\Users\tdeschryver\dev\ngx-drag-to-select\node_modules\ng-packagr\lib\ngc\compile-source-files.js:53:68)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\tdeschryver\dev\ngx-drag-to-select\node_modules\ng-packagr\lib\ngc\compile-source-files.js:4:58)
projects/ngx-drag-to-select/src/lib/operators.ts(6,14): error TS4023: Exported variable 'createSelectBox' has or is using name 'MousePosition' from external module "C:/Users/tdeschryver/dev/ngx-drag-to-select/projects/ngx-drag-to-select/src/lib/models" but cannot be named.
Error: projects/ngx-drag-to-select/src/lib/operators.ts(6,14): error TS4023: Exported variable 'createSelectBox' has or is using name 'MousePosition' from external module "C:/Users/tdeschryver/dev/ngx-drag-to-select/projects/ngx-drag-to-select/src/lib/models" but cannot be named.
at Object.<anonymous> (C:\Users\tdeschryver\dev\ngx-drag-to-select\node_modules\ng-packagr\lib\ngc\compile-source-files.js:53:68)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\tdeschryver\dev\ngx-drag-to-select\node_modules\ng-packagr\lib\ngc\compile-source-files.js:4:58)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, indeed. This makes sense. The compiler is trying to figure out the shape of MouseEvent
but it can't cause it's defined in a different module and never imported to the operators.ts
module. So we can just add the type annotation and remove the comment I guess. What do you think? Or should we keep the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid future us will try to remove it 😅 and bumping into this problem again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha you're right, we can leave it in then. Maybe let's reword this to Type annotation is required here, because 'getRelativeMousePosition' return a 'MousePosition' and the TS compiler cannot figure out the shape of this type.
, or something along those lines 🙂
46658df
to
4d8f86c
Compare
9e8af8c
to
a07de70
Compare
package.json
Outdated
"test:ci": "npm run test && start-server-and-test start http-get://localhost:4200 e2e:ci", | ||
"test:watch": "jest --watch", | ||
"test:watch": "npm run test -- --watch", | ||
"lint:check": "ng lint", | ||
"lint:fix": "ng lint --fix", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command is broken with the latest CLI. It doesn't allow multiple apps for a single command I suppose. We have to change this to ng lint app --fix && ng lint ngx-drag-to-select --fix
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch, you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the --project
flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope we don't! I also removed the --project
flag in the build scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay 🎉
6366723
to
41d246f
Compare
41d246f
to
f3a3e9e
Compare
f3a3e9e
to
df00157
Compare
Woho 🎉 We finally made it to Angular 6. Thanks so much @timdeschryver for all the work you put into this PR. I really appreciate your help. |
No description provided.