バンドル ファイルの aurelia.io フレームワークを使用し、SystemJS を使用して構成された小さな TypeScript helloworld アプリケーションがあります。アプリを実行すると、コンパイル済みの typescript バージョンで次のhelloworld.ts
ようなエラーがスローされます。
TypeError: define is not a function at System.register.execute
(http://localhost:9000/src/helloworld.js!eval:31:13) at t ...
関数define
が SystemJS によって宣言されているように見えるので、おそらくこれは構成の問題です。フレームワークは正常に読み込まれているようですが、systemjs 関数が認識されないのは非常に奇妙です。
これが私のプロジェクト階層と構成ファイルです。私は何を間違っていますか?
私のフォルダ構造は次のようになります。
./jspm_packages/...
./scripts/aurelia/aulrelia-bundle.js
./src/main.ts
./src/main.js (compiled ts)
./src/app.ts
./src/app.js (compiled ts)
./src/helloworld.ts
./src/helloworld.js (compiled ts)
./index.html
./config.js
jspm をインストールし、プロンプトに従ってデフォルトの config.js ファイルを作成しました。デフォルトから変更した唯一のオプションは、babel をトランスパイラーとして使用することでした。
私の config.js は次のようになります。
System.config({
"baseURL": "/",
"transpiler": "babel",
"babelOptions": {
"optional": [
"runtime"
]
},
"paths": {
"*": "*.js",
"github:*": "jspm_packages/github/*.js",
"npm:*": "jspm_packages/npm/*.js"
}
});
System.config({
"map": {
"babel": "npm:babel-core@5.5.6",
"babel-runtime": "npm:babel-runtime@5.5.6",
"core-js": "npm:core-js@0.9.15",
"github:jspm/nodelibs-process@0.1.1": {
"process": "npm:process@0.10.1"
},
"npm:babel-runtime@5.5.6": {
"process": "github:jspm/nodelibs-process@0.1.1"
},
"npm:core-js@0.9.15": {
"fs": "github:jspm/nodelibs-fs@0.1.2",
"process": "github:jspm/nodelibs-process@0.1.1",
"systemjs-json": "github:systemjs/plugin-json@0.1.0"
}
}
});
私の index.html は次のようになります。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hello World</title>
<link rel="stylesheet" type="text/css" href="styles/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="styles/fontawesome/css/font-awesome.min.css">
<link href="styles/styles.css" rel="stylesheet" />
</head>
<body aurelia-app>
<div class="splash">
<div class="message">Welcome...</div>
</div>
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.config({
"paths": {
"*": "*.js"
}
});
//Project uses bundles
System.bundles["scripts/aurelia/aurelia-bundle"]=["aurelia-bootstrapper"];
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
私helloword.ts
はこのように見えます:
import {bindable} from 'aurelia-framework';
export class HelloWorld{
@bindable hello="Hello!";
}
完全なエラー:
TypeError: define is not a function at System.register.execute
(http://localhost:9000/src/helloworld.js!eval:31:13) at t
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:19798) at v
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:20180) at u
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:19856) at s
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:19737) at
http://localhost:9000/jspm_packages/es6-module-loader.js:7:22064 at O
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:7439)
at K
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:7071) at y.7.y.when
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:10745) at v.7.v.run
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:9781) at a.3.a._drain
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:1740)
at 3.a.drain
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:1394) at MutationObserver.b
(http://localhost:9000/jspm_packages/es6-module-loader.js:7:3302)(anonymous function) @ aurelia-bundle.js:16334run @ aurelia-bundle.js:1602(anonymous
function) @ aurelia-bundle.js:1613module.exports @ aurelia-bundle.js:2906queue.(anonymous function) @ aurelia-bundle.js:3416run @ aurelia-bundle.js:3404listner @ aurelia-bundle.js:3408