-
Notifications
You must be signed in to change notification settings - Fork 47
build: update build process to conform to Angular Package Format #51
Conversation
This PR is meant to stop packaging full TypeScript files in the library. This breaks testing capabilities in Angular, and is overall unnecessary. Instead, we transpile all files using tsc into a separate directory, and only publish that directory, with the root files (index.js and index.d.ts) specified in package.json. There are no breaking changes in this PR, but if you are building from source, please make sure to update your dev dependencies. * add outDir to tsconfig for bundling * upgrade to angular v5 and use new compiler instead of just tsc * clean up package.jsom npm scripts * add exports to index.ts to allow for root import * move inline builder to separate directory * add dev dependencies for TypeScript building * add files and directories to npmignore to allow for root packaging * move protractor config to root level * change webpack to use ts-loader * Fixes angular#49 BREAKING CHANGE: Due to the change in how folders are exported, all imports from `preboot` must come as a root import, e.g. `import {ServerPrebootModule} from 'preboot';` instead of `import {ServerPrebootModule} from 'preboot/server';`
70b6639 to
b968e82
Compare
jeffwhelpley
left a 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.
@CaerusKaru when I pull this locally and try it out, I am getting a number of errors. Specifically, I did the following:
npm inpm run build
and I got the following:
ES2015 compilation succeeded.
ES5 compilation succeeded.
Typings and metadata copy succeeded.
options.entry is deprecated, use options.input
options.entry is deprecated, use options.input
options.entry is deprecated, use options.input
options.entry is deprecated, use options.input
Build failed. See below for errors.
Error: Unexpected key 'dest' found, expected one of: acorn, amd, banner, cache, context, entry, exports, extend, external, file, footer, format, globals, indent, input, interop, intro, legacy, moduleContext, name, noConflict, onwarn, output, outro, paths, plugins, preferConst, pureExternalModules, sourcemap, sourcemapFile, strict, targets, treeshake, watch
at validateKeys (/Users/jeffwhelpley/opensource/temp/preboot/node_modules/rollup/dist/rollup.js:171:11)
at checkInputOptions (/Users/jeffwhelpley/opensource/temp/preboot/node_modules/rollup/dist/rollup.js:16349:14)
at Object.rollup (/Users/jeffwhelpley/opensource/temp/preboot/node_modules/rollup/dist/rollup.js:16420:3)
at allBundles.map.cfg (/Users/jeffwhelpley/opensource/temp/preboot/build.js:128:25)
at Array.map (<anonymous>)
at Promise.resolve.then.then.then.then.then (/Users/jeffwhelpley/opensource/temp/preboot/build.js:128:7)
at <anonymous>
Then I just tried to tsc and got:
integration/src/app/app.module.ts(6,48): error TS2307: Cannot find module 'preboot'.
integration/src/prerender.ts(4,43): error TS2307: Cannot find module 'fs-extra'.
out-tsc/lib/api/event.recorder.spec.ts(5,3): error TS2305: Module '"/Users/jeffwhelpley/opensource/temp/preboot/out-tsc/lib/index"' has no exported member 'Element'.
out-tsc/lib/api/event.recorder.spec.ts(25,27): error TS2345: Argument of type 'HTMLElement | undefined' is not assignable to parameter of type 'Expected<HTMLElement>'.
Type 'undefined' is not assignable to type 'Expected<HTMLElement>'.
out-tsc/lib/api/event.recorder.spec.ts(36,9): error TS2322: Type '() => { style: { display: string; }; }' is not assignable to type '(deep?: boolean | undefined) => Node'.
Type '{ style: { display: string; }; }' is not assignable to type 'Node'.
Property 'attributes' is missing in type '{ style: { display: string; }; }'.
out-tsc/lib/api/event.recorder.spec.ts(42,27): error TS2345: Argument of type '{ style: { display: string; }; }' is not assignable to parameter of type 'Expected<HTMLElement>'.
Type '{ style: { display: string; }; }' is not assignable to type 'ObjectContaining<HTMLElement>'.
Property 'jasmineMatches' is missing in type '{ style: { display: string; }; }'.
out-tsc/lib/api/event.recorder.spec.ts(100,13): error TS2322: Type '{ root: { serverSelector: string; serverNode: {}; }; events: never[]; }' is not assignable to type 'PrebootAppData'.
Types of property 'root' are incompatible.
Type '{ serverSelector: string; serverNode: {}; }' is not assignable to type 'ServerClientRoot'.
Types of property 'serverNode' are incompatible.
Type '{}' is not assignable to type 'HTMLElement | undefined'.
Type '{}' is not assignable to type 'HTMLElement'.
Property 'accessKey' is missing in type '{}'.
out-tsc/lib/api/event.recorder.spec.ts(114,87): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'EventListenerOrEventListenerObject' has no compatible call signatures.
out-tsc/lib/api/inline.preboot.code.spec.ts(8,9): error TS2305: Module '"/Users/jeffwhelpley/opensource/temp/preboot/out-tsc/lib/common/preboot.interfaces"' has no exported member 'PrebootRecordOptions'.
out-tsc/lib/common/get-node-key.spec.ts(25,27): error TS2352: Type '{ root: { serverSelector: string; serverNode: { childNodes: ({} | { childNodes: ({} | { childNode...' cannot be converted to type 'NodeContext'.
Types of property 'root' are incompatible.
Type '{ serverSelector: string; serverNode: { childNodes: ({} | { childNodes: ({} | { childNodes: {}[];...' is not comparable to type 'ServerClientRoot'.
Types of property 'serverNode' are incompatible.
Type '{ childNodes: ({} | { childNodes: ({} | { childNodes: {}[]; })[]; })[]; }' is not comparable to type 'HTMLElement | undefined'.
Type '{ childNodes: ({} | { childNodes: ({} | { childNodes: {}[]; })[]; })[]; }' is not comparable to type 'HTMLElement'.
Property 'accessKey' is missing in type '{ childNodes: ({} | { childNodes: ({} | { childNodes: {}[]; })[]; })[]; }'.
src/lib/api/event.recorder.spec.ts(5,3): error TS2305: Module '"/Users/jeffwhelpley/opensource/temp/preboot/src/lib/index"' has no exported member 'Element'.
src/lib/api/event.recorder.spec.ts(25,27): error TS2345: Argument of type 'HTMLElement | undefined' is not assignable to parameter of type 'Expected<HTMLElement>'.
Type 'undefined' is not assignable to type 'Expected<HTMLElement>'.
src/lib/api/event.recorder.spec.ts(36,9): error TS2322: Type '() => { style: { display: string; }; }' is not assignable to type '(deep?: boolean | undefined) => Node'.
Type '{ style: { display: string; }; }' is not assignable to type 'Node'.
Property 'attributes' is missing in type '{ style: { display: string; }; }'.
src/lib/api/event.recorder.spec.ts(42,27): error TS2345: Argument of type '{ style: { display: string; }; }' is not assignable to parameter of type 'Expected<HTMLElement>'.
Type '{ style: { display: string; }; }' is not assignable to type 'ObjectContaining<HTMLElement>'.
Property 'jasmineMatches' is missing in type '{ style: { display: string; }; }'.
src/lib/api/event.recorder.spec.ts(100,13): error TS2322: Type '{ root: { serverSelector: string; serverNode: {}; }; events: never[]; }' is not assignable to type 'PrebootAppData'.
Types of property 'root' are incompatible.
Type '{ serverSelector: string; serverNode: {}; }' is not assignable to type 'ServerClientRoot'.
Types of property 'serverNode' are incompatible.
Type '{}' is not assignable to type 'HTMLElement | undefined'.
Type '{}' is not assignable to type 'HTMLElement'.
Property 'accessKey' is missing in type '{}'.
src/lib/api/event.recorder.spec.ts(114,87): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'EventListenerOrEventListenerObject' has no compatible call signatures.
src/lib/api/inline.preboot.code.spec.ts(8,9): error TS2305: Module '"/Users/jeffwhelpley/opensource/temp/preboot/src/lib/common/preboot.interfaces"' has no exported member 'PrebootRecordOptions'.
src/lib/common/get-node-key.spec.ts(25,27): error TS2352: Type '{ root: { serverSelector: string; serverNode: { childNodes: ({} | { childNodes: ({} | { childNode...' cannot be converted to type 'NodeContext'.
Types of property 'root' are incompatible.
Type '{ serverSelector: string; serverNode: { childNodes: ({} | { childNodes: ({} | { childNodes: {}[];...' is not comparable to type 'ServerClientRoot'.
Types of property 'serverNode' are incompatible.
Type '{ childNodes: ({} | { childNodes: ({} | { childNodes: {}[]; })[]; })[]; }' is not comparable to type 'HTMLElement | undefined'.
Type '{ childNodes: ({} | { childNodes: ({} | { childNodes: {}[]; })[]; })[]; }' is not comparable to type 'HTMLElement'.
Property 'accessKey' is missing in type '{ childNodes: ({} | { childNodes: ({} | { childNodes: {}[]; })[]; })[]; }'.
utils/preboot.mocks.ts(1,34): error TS2305: Module '"/Users/jeffwhelpley/opensource/temp/preboot/src/lib/index"' has no exported member 'Element'.
utils/preboot.mocks.ts(1,43): error TS2305: Module '"/Users/jeffwhelpley/opensource/temp/preboot/src/lib/index"' has no exported member 'PrebootRecordOptions'.
utils/preboot.mocks.ts(1,65): error TS2305: Module '"/Users/jeffwhelpley/opensource/temp/preboot/src/lib/index"' has no exported member 'Window'.
So, are you still working on this? If so, just let me know when you want me to try it out.
| @@ -0,0 +1,70 @@ | |||
| { | |||
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.
Instead of package-lock.json, we should probably include a shrinkwrap file.
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.
Added, and removed package-lock.json
|
Btw, if you want to jump on a hangout to work on this together at any point, just let me know. |
|
You're having issues with building because I suspect your version of rollup is too high. They don't follow semver, so the latest version (0.51.x) is incompatible with build config for the version that's used here and by the other Angular libraries (0.41.x). I'll update the package.json to reflect this. As for the tsc issues, my build runs fine, what version of TypeScript are you using? Since Angular 5 compiler still only supports TypeScript 2.4.2, that's the version I'm using here (I'll change this in the package.json too). I'd be happy to hop on a Hangout (my Google username is caerus.karu), the only issue I'm still facing is the e2e testing bug. Everything builds successfully, but the EventReplayer won't kick in on its own during bootstrap (although it works fine in real applications). |
1d0ebc9 to
49fd4ca
Compare
|
@jeffwhelpley Just for the record, here's my build process at the moment (I'll cut it down for the official release):
You should see at the point that the e2e passes the first two tests, but fails on the next two |
|
@jeffwhelpley This is ready to be merged, I resolved the final e2e issue (which turned out to be a good thing because the timing on the EventReplayer was very off). The official commands to run the build are close to the old version:
This will build the library and run the e2e tests. At some point we'll probably want to incorporate some unit tests as well, but that's been left as a stub for now. Let me know what you think, and if any other changes are needed. |
b2f67c1 to
38c0eb3
Compare
|
@jeffwhelpley Just touching up the spec type issues you noted above (I finally read through and realized my build wasn't catching those type errors for some reason). I'll ping you when this is resolved, which should be in the next few minutes (sorry for the ping spam). |
|
@jeffwhelpley type issues resolved, everything should be set |
|
@CaerusKaru ok, this is definitely going in the right direction but I still have a few more questions. Rather than go back an forth on here, let's just do a Google Hangout Monday or Tuesday night this week to wrap things up. Send me your email to jeff at gethuman dot com. |
043da31 to
5f29b09
Compare
9c441d1 to
c0ddc16
Compare
|
Is there anything else blocking this PR? |
|
@mgol apologies, we are still working out one issue. We will get this resolved today. |
* Still maintains compatibility with non-Angular library for direct import * AOT compatible, compiled with Angular v5 * Removes separate ServerPreboot and BrowserPreboot and respective options in favor of combining them into one module * Allows for top-level imports on everything * Add build for ES5 and ES2015 bundles * Add karma testing capability * Credit to angular-quickstart-lib for a lot of the scaffolding * Credit to flex-layout and material packages for remaining work
|
OK, @mgol @CaerusKaru I merged in this PR and published it under |
|
There is an issue with styles. After switching to front part. They have no styles applied. I.e. But styles only for _ngcontent-c1 |
|
@misticwonder Can you link to a minimal reproduction repo so we can check this out? |
|
I've found a problem. In my project appRef.isStable is never true. |
|
There is another issue: |
|
@misticwonder Please open a separate issue with a minimal reproduction instead of appending to this PR |
This is the improved version of #50. Preboot will now use the same bundling method that Angular Material and Flex-Layout use.
ngc) to produce ES5 and ES2015 bundlesServerPrebootModuleandBrowserPrebootModuleinto a singularPrebootModule, also combinePrebootReplayOptionsandPrebootRecordOptionsintoPrebootOptionsimport {...} from 'preboot/server';-->import {...} from 'preboot';BREAKING CHANGE:
ServerPrebootModuleorBrowserPrebootModuleneed to be removed in favor ofPrebootModule, and all relative imports need to be changed to import directly fromprebootFixes #49
Fixes #52