angular-polymer icon indicating copy to clipboard operation
angular-polymer copied to clipboard

Can't Use in Angular cli 22

Open rumes opened this issue 8 years ago • 15 comments

Can't add vaadin in angular cli 22. If we use

main-polymer.ts

document.addEventListener('WebComponentsReady', () => {
  require('./main.ts');
  true;
});

because BoostrapModule wrap by another function in this case addEventListener it give error

Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.

rumes avatar Dec 06 '16 17:12 rumes

You probably getting this error because you are building with --aot option. Try building without --aot.

virusakos avatar Dec 06 '16 21:12 virusakos

in 22 it is not a option it is embeded as i here. And as I here now on every angular2 3rd party library must have aot compatibility to use in angular cli. I thin vaadin not have that.

rumes avatar Dec 07 '16 04:12 rumes

with --aot I have this error :

Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.

Chabane avatar Dec 08 '16 11:12 Chabane

Have the same problem :-/ :

Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
Error: Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
    at Object.resolveEntryModuleFromMain ([...]\node_modules\@ngtools\webpack\src\entry_resolver.js:121:15)
    at AotPlugin._setupOptions ([...]\node_modules\@ngtools\webpack\src\plugin.js:129:58)
    at new AotPlugin ([...]\node_modules\@ngtools\webpack\src\plugin.js:37:14)
    at Object.exports.getWebpackNonAotConfigPartial ([...]\node_modules\angular-cli\models\webpack-build-typescript.js:20
:13)
    at new NgCliWebpackConfig ([...]\node_modules\angular-cli\models\webpack-config.js:23:42)
    at Class.run ([...]\node_modules\angular-cli\tasks\serve-webpack.js:20:22)
    at [...]\node_modules\angular-cli\commands\serve.js:102:26
    at process._tickCallback (internal/process/next_tick.js:103:7)

MarcelMalik avatar Dec 11 '16 04:12 MarcelMalik

Same here...

Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
Error: Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
    at Object.resolveEntryModuleFromMain (.../node_modules/@ngtools/webpack/src/entry_resolver.js:121:15)
    at AotPlugin._setupOptions (.../node_modules/@ngtools/webpack/src/plugin.js:129:58)
    at new AotPlugin (.../node_modules/@ngtools/webpack/src/plugin.js:37:14)
    at Object.exports.getWebpackNonAotConfigPartial (.../node_modules/angular-cli/models/webpack-build-typescript.js:20:13)
    at new NgCliWebpackConfig (.../node_modules/angular-cli/models/webpack-config.js:23:42)
    at Class.exports.default.Task.extend.run (.../node_modules/angular-cli/tasks/build-webpack.js:17:22)
    at Class.Command.extend.run (.../node_modules/angular-cli/commands/build.js:54:26)
    at Class.<anonymous> (.../node_modules/angular-cli/angular-cli/lib/models/command.js:152:17)
    at process._tickCallback (internal/process/next_tick.js:103:7)

erdem-aslan avatar Dec 12 '16 12:12 erdem-aslan

I try to fixed the error with modifying the "entry_resolver.js" as suggested (https://github.com/angular/angular-cli/issues/2887) and changed line 109 from this: var bootstrap = source.findAstNodes(source.sourceFile, ts.SyntaxKind.CallExpression, false) to this: var bootstrap = source.findAstNodes(source.sourceFile, ts.SyntaxKind.CallExpression, true).

And move the content of main-polymer.ts to the main.ts file:

...
document.addEventListener('WebComponentsReady', () => {
  platformBrowserDynamic().bootstrapModule(AppModule);
});
// platformBrowserDynamic().bootstrapModule(AppModule);

but then I get problems with the registrations in the app.module.ts:

UnhandledPromiseRejection Warning: Unhandled promise rejection (rejection id: 1): Error: Error encountered resolving symbol values statically. Calling function 'PolymerElement', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function

MarcelMalik avatar Dec 12 '16 13:12 MarcelMalik

I was trying some work around, and maybe this could help you:

main.ts

var webComponentsFlag = false;
document.addEventListener('WebComponentsReady',() =>{
  if (!webComponentsFlag)
    platformBrowserDynamic().bootstrapModule(AppModule);
  webComponentsFlag = true;
});
if (webComponentsFlag)
 platformBrowserDynamic().bootstrapModule(AppModule);

this allows to build the project

axtlotic avatar Dec 12 '16 18:12 axtlotic

Seems to be a dupe of https://github.com/vaadin/angular2-polymer/issues/86. Note that the Angular CLI beta.22 is quite broken in a number of ways.

Splaktar avatar Dec 13 '16 18:12 Splaktar

The two proposals I shared allowed to compile a project with Angular cli 22 (#111, #86), I hope helps you.

axtlotic avatar Dec 13 '16 23:12 axtlotic

Angular CLI beta.23 is out and fixes an issue with stripping out custom decorators. It looks like this will still be a problem due to #86 though.

Splaktar avatar Dec 16 '16 18:12 Splaktar

Still no fix for this?

jonathansolorzn avatar Jan 18 '17 01:01 jonathansolorzn

Is there any way to fix this?

GuzmanPI avatar Jan 31 '17 04:01 GuzmanPI

I'm also facing the same error

fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options. Error: Tried to find bootstrap code, but could not. Specify either statically an alyzable bootstrap code or pass in an entryModule to the plugins options. at Object.resolveEntryModuleFromMain (C:\practice\my-project\node_modules@ngtools\webpack\src\entry_resolver.js:121:15) at AotPlugin._setupOptions (C:\practice\my-project\node_modules@ngtools\webpack\src\plugin.js:174:50) at new AotPlugin (C:\practice\my-project\node_modules@ngtools\webpack\src\plugin.js:21:14) at Object.exports.getNonAotConfig (C:\practice\my-project\node_modules\angular-cli\models\webpack-configs\typescript.js:26:13) at new NgCliWebpackConfig (C:\practice\my-project\node_modules\angular-cli\models\webpack-config.js:24:37) at Class.run (C:\practice\my-project\node_modules\angular-cli\tasks\serve.js:31:29) at C:\practice\my-project\node_modules\angular-cli\commands\serve.run.js:22:22 at process._tickCallback (internal/process/next_tick.js:103:7)

I have created the project by follow the link https://vaadin.com/vaadin-documentation-portlet/elements/angular2-polymer/ng-cli-webpack.html

can anyone help to resolve these.

nunna-suma avatar Feb 08 '17 11:02 nunna-suma

Hi @nunna-suma

We will begin to work on a fix as soon as possible. But to support AoT a lot of changes are necessary. We will keep you updated and if anybody could help us develop please raise your voice here: https://github.com/platosha/angular-polymer/issues/123

I think a fix will be published in a few months the soonest.

BorntraegerMarc avatar Feb 08 '17 11:02 BorntraegerMarc

I put the WebComponentsReady listener directly into the main.ts. I tested it by putting a trivial combo-box and it worked.

Replace platformBrowserDynamic().bootstrapModule(AppModule); with the below.

document.addEventListener('WebComponentsReady', () =>{
  platformBrowserDynamic().bootstrapModule(AppModule);
});

ryalman avatar Feb 15 '17 17:02 ryalman