Runtime fails to find the function entry points when code is built with typescript
See original GitHub issueIf the basic JS example code is tweaked to use the azure-functions-typescript typings the local runtime fails with errors and Azure gives a 500.
A ScriptHost error has occurred
[19/08/2017 15:55:42] Exception while executing function: Functions.test. mscorlib: Unable to determine function entry point. If multiple functions are exported, you must indicat
e the entry point, either by naming it 'run' or 'index', or by naming it explicitly via the 'entryPoint' metadata property.
From TS
/* 231 */
/***/ (function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function index(context, req) {
...
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
"test": __webpack_require__(231)
}
From JS
/* 0 */
/***/ (function(module, exports) {
module.exports = function(context, req) {
...
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
"test": __webpack_require__(0)
}
The webpack_require definition is the same in both, but the import ordinal is different
The TS generated JS is different to the sample with a prefix and postscript added. both related to exports
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function index(context, req) {
... same code as sample
}
exports.index = index;
Hopefully is just a matter of finding the correct module exports format for TS. It’s not clear why webpack behaves differently.
Anyone have good knowledge here?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Unable to determine function entry point - azure - Stack Overflow
Made two very inconsequential code changes and pushed on Friday and no I'm getting: Exception while executing function: Functions.messages.
Read more >Azure Functions + Node.js + TypeScript + Webpack
[error] Worker was unable to load function QueueTrigger: 'Unable to determine function entry point. If multiple functions are exported, you must ...
Read more >Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >Documentation - The Basics - TypeScript
When we run our code, the way that our JavaScript runtime chooses what to do is by figuring out the type of the...
Read more >Documentation - ECMAScript Modules in Node.js - TypeScript
This code works in CommonJS modules, but will fail in ES modules because relative import paths need to use extensions. As a result,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The answer turns out to be simple, use the
export =
form in typescript which resolves tomodule.exports =
eg
export = function index(context: HttpContext, req: IFunctionRequest): void {
In addition to the solution from @SteveALee, I also had to set my Webpack config (using Webpack 4.8.1) to use:
libraryTarget: 'commonjs2'
, which creates an output file withmodule.exports = ...
rather than justexports = ...
(See explanation here: https://github.com/webpack/webpack/issues/1114)