I'm in the process of learning systemjs and the whole ES6 module backporting to older browsers.
As a educational piece i'm trying just to load jquery and do a simple "Hello world!" using alert()
Now, I got systemjs running up to a point where it loads typescript and jquery but is failing a few seconds after the page loads with the following error:
Error: (SystemJS) jquery_1.$ is not a function
TypeError: jquery_1.$ is not a function
at execute (http://localhost/webpMain/main.js!transpiled:12:22)
Error loading http://localhost/webpMain/main.js
at execute (http://localhost/webpMain/main.js!transpiled:12:22)
Error loading http://localhost/webpMain/main.js
The page is just a huge red box, and if it gets clicked it's supposed to just alert "Hello world".
This is the markup:
<!DOCTYPE html>
<html lang="us">
<head>
<title>SystemJS Test</title>
<script src="node_modules\systemjs\dist\system.js"></script>
<script src="system.config.js"></script>
<style>
#box {
width: 300px;
height: 300px;
position: absolute;
background: red;
}
</style>
</head>
<body>
<div id="box"></div>
</body>
<script>
System.import("app")
.catch(function(err) {
console.log(err);
});
</script>
</html>
The systemjs configuration file:
System.config({
paths: {
"npm:*": "node_modules/*"
},
map: {
app: 'webpMain',
'typescript': 'npm:typescript/lib/typescript.js',
'jquery': 'npm:jquery/dist/jquery.min.js'
},
packages: {
app: {
main: 'main.js'
}
},
transpiler: 'typescript',
});
And the main.js
import { $ } from "jquery";
$("box").click(function() {
alert("Hello world!!");
});
- Any ideas why the jquery import is not working?
- What is displaying that error, typescript or systemjs?