aurelia - error using material-components-web with skelton-esnext project

时间:2017-08-30 20:34:13

标签: aurelia material-components

I've successfully used the material-components-web library from within my aurelia skeleton-esnext-webpack projects but I am strugling to get them working in a skeleton-esnext project.

The problem seems to be with the fact that the skeleton-esnext project uses jspm with system.js as its module loader.

I have added <img> to the jspm dependencies section of my package.json which seems to install the correct @material libraries to my jspm_modules/npm/@material.

Now, when I try to access any class from this library from within any my aurelia view models

SELECT * 
FROM table1 t
where not exists(
select * from table2 l where t.loco_id=l.loco_id and
t.a=l.a and
t.b=l.b
);

I get the following error in the browser when I run the project:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Ace & Emmet Pack</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <style type="text/css">
        #editor { font-size: 12pt; font-family: monospace; }
    </style>
</head>
<body>
    <pre id="editor"></pre>
    <script text="type/javascript" src="https://cloud9ide.github.io/emmet-core/emmet.js"></script>
    <script text="type/javascript" src="ace/demo/r.js/packed.js"></script>
    <script text="type/javascript">
        require("ace/config").set("basePath", "ace/build/src");
        require("ace/config").set("packaged", true);
        const editor = require("ace/ace").edit("editor");
        editor.session.setMode("ace/mode/html");
        editor.setOptions({
            maxLines: 25,
            autoScrollEditorIntoView: true
        });
        editor.setValue(
            "<p>Hello the World !</p>\n" +
            "<p>packed.js was built as explained in ace/demo/r.js/</p>\n" +
            "<p>Emmet is not working !</p>\n"
        );
        var Emmet = require("ace/config").loadModule(
            "ace/ext/emmet",
            function(module) {
                editor.setOption("enableEmmet", true);
            }
        );
    </script>
</body>
</html>`

Any suggestions to whats most likely causing this issue?

1 个答案:

答案 0 :(得分:0)

SystemJS正在导入插件的原始源文件而不是已编译的源文件(如果您查看jspm_packages/npm/@material/textfield@0.3.6.js,可以看到这一点。

您可以通过更改其中的位置来指向目录dist的{​​{1}}目录来修复它。但是,它会在潜在更新时始终被覆盖。它不会保存在CVS中。

另一种更简单的方法是在视图模型中导入正确的文件:

textfield@0.3.6