khashayar / ng-trim-value-accessor

Angular's (missing) trim accessor to automatically trim values of input fields
MIT License
53 stars 19 forks source link

Does not run with Angular 5 #9

Closed moritz-h closed 6 years ago

moritz-h commented 7 years ago

Tested with a new empty project (Angular CLI 1.5.0 and Angular 5) ng new test-project npm install ng-trim-value-accessor --save (include like in README) ng serve

ERROR in ./node_modules/ng-trim-value-accessor/index.ts
Module build failed: Error: [...]/node_modules/ng-trim-value-accessor/index.ts is not part of the compilation output. Please check the other error messages for details.
    at AngularCompilerPlugin.getCompiledFile ([...]/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:629:23)
    at plugin.done.then ([...]/node_modules/@ngtools/webpack/src/loader.js:467:39)
    at process._tickCallback (internal/process/next_tick.js:109:7)
 @ ./src/app/app.module.ts 9:0-65
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Found a similar issue with workaround here: https://github.com/angular/angular/issues/20091

moritz-h commented 7 years ago

Found some more infos: The problem could be that you are providing .ts files in the npm package. See the second half of this comment:

So we don't really support using incorrectly packaged libraries with TS sources. It's something you do at your risk. https://github.com/angular/angular-cli/issues/8284#issuecomment-341417325

moritz-h commented 7 years ago

I can now confirm the *.ts files in the library as error source. As quick check I tried the following:

clone your repo
npm install
npm install --save-dev @types/es6-shim (needed for build)
npm run build
copy the dist/ folder to my-app/node_modules/ng-trim-value-accessor/

My app then builds without problems.

khashayar commented 7 years ago

Thanks for the report and rundown. Do you mind submitting a PR for that?

moritz-h commented 7 years ago

I don't know if I can help with this. I have no experience in creating modules or in publishing anything on npm yet. I only know, that providing .ts files in a module is wrong from the above linked comment. So it must be something like "compile before uploading it to npm", but how exactly to do this is the question :-)

moritz-h commented 7 years ago

Ok seems not to hard. I can try making a PR. Infos from: http://ljn.io/posts/publishing-typescript-projects-with-npm/ https://www.twilio.com/blog/2017/06/writing-a-node-module-in-typescript.html https://stackoverflow.com/questions/30928253/writing-npm-modules-in-typescript

khashayar commented 6 years ago

@moritz-h Can you please verify whether the latest version works for you?

moritz-h commented 6 years ago

@khashayar Looks good. ng serve runs now also without --aot. In node_module/ng-trim-value-accessor/ are now only the .js and .d.ts files. No other .ts sources. :+1:

khashayar commented 6 years ago

Great! Thanks for the PR!