Reputation: 4663
My target is to call an exported function. I'm following the official documentation and have this:
// Test.ts
export function test():void
{
console.log("QWERTY");
}
// Main.ts
import {test} from "./third_party/Test"
window.onload = () => {
test();
}
// index.html
<!DOCTYPE html>
<html lang="en">
<head>
<script src="build/library.js"></script>
</head>
</html>
// tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "amd",
"sourceMap": true,
"outFile": "build/library.js"
}
}
Running the web page I have ReferenceError: define is not defined at /mypath/build/library.js:1:2
.
What's going on?
Upvotes: 0
Views: 1188
Reputation:
You need to have a module loader already loaded up.
Modules import one another using a module loader. At runtime the module loader is responsible for locating and executing all dependencies of a module before executing it. Well-known modules loaders used in JavaScript are the CommonJS module loader for Node.js and require.js for Web applications.
How to get started with RequireJS
Upvotes: 3