Skip to content
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

Add requirement for main.ts on the server in README.md #12

Closed
sclausen opened this issue Oct 2, 2015 · 12 comments
Closed

Add requirement for main.ts on the server in README.md #12

sclausen opened this issue Oct 2, 2015 · 12 comments

Comments

@sclausen
Copy link
Contributor

sclausen commented Oct 2, 2015

You can't choose another main-module than main.ts on the server, because it is hardcoded in barbatus:angular2.

@barbatus
Copy link
Collaborator

barbatus commented Oct 2, 2015

Yes, I'll add it for sure. Though, presence of main.ts is not required like you said; if it's there it'll be imported if it's not you'll need to import another module manually.

@sclausen
Copy link
Contributor Author

sclausen commented Oct 2, 2015

How do you import another module on the server to be executed at startup?

@barbatus
Copy link
Collaborator

barbatus commented Oct 2, 2015

Same way you'd do it for client side:
add main.js with

Meteor.startup(function(){
 System.import('server/foo').await();
})

@sclausen
Copy link
Contributor Author

sclausen commented Oct 2, 2015

Hmm, maybe I got the wrong idea how stuff works, bu if you don't create a main.ts on the server, no code will be executed there, so where would you define this import?

@sclausen
Copy link
Contributor Author

sclausen commented Oct 2, 2015

Maybe I slowly got it. js files are executed normally without being registered as system.js modules, so
I could create a foo.js on the server with

Meteor.startup(function(){
 System.import('server/foo').await();
})

right!?

@barbatus
Copy link
Collaborator

barbatus commented Oct 2, 2015

@sclausen yes, exactly. foo.ts

@sclausen
Copy link
Contributor Author

sclausen commented Oct 2, 2015

Hmm, but the server doesn't know about system.js…

While processing files with barbatus:angular2 (for target
   os.linux.x86_64):
   /server/notmain.ts:16:2: Cannot find name 'System'.

Do I have to manually add systemjs:systemjs to my project, or am I doing something still wrong?
I think this would be an inconvenient workaround to use something different than the automatically loaded main.ts.

@barbatus
Copy link
Collaborator

barbatus commented Oct 2, 2015

You seem to be missing something. If there wasn't System defined on the server, it wouldn't work even with main.ts.

@barbatus
Copy link
Collaborator

barbatus commented Oct 2, 2015

systemjs:systemjs should be added to your app by the package.

@sclausen
Copy link
Contributor Author

sclausen commented Oct 2, 2015

Okay, I don't know, what I did wrong before. Everything now works as expected. The custom import in a server-side js-file works like a charm.

@barbatus
Copy link
Collaborator

barbatus commented Oct 2, 2015

Use System in pure .js-files, in .ts ones you don't need it

@sclausen
Copy link
Contributor Author

sclausen commented Oct 2, 2015

Yeah I know, I got that after writing my third comment in this issue, but I did something wrong and was confused about the server not knowing anything about the systemjs:systemjs in my js-file although added it in barbatus:angular2… Thanks for clarification! ☺️

@barbatus barbatus closed this as completed Oct 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants