在Relay中包含Typescript代码(System.js导入)

时间:2016-02-08 18:02:26

标签: javascript typescript systemjs relay

如何包含system.js来修复下面的错误?或者还有其他解决方案吗?

我下载了relay-starter-kit(https://github.com/relayjs/relay-starter-kit),将database.js更改为具有以下内容的数据库。(Snippet 1)。

我运行了“npm run update-schema”并收到了错误

<profiles>
    <profile>
        <id>Live</id>
        <properties>
            <datasourceUrl>url1</datasourceUrl>
        </properties>
    </profile>

    <profile>
        <id>Test</id>
        <properties>
            <datasourceUrl>url2</datasourceUrl>
        </properties>
    </profile>
</profiles>


<build>
    <defaultGoal>install</defaultGoal>
    <resources>
        <resource>
            <directory>${basedir}/src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*.*</include>

            </includes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
            <executions>
                <execution>
                    <id>run</id>
                    <phase>package</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>

            <executions>
                <execution>
                    <id>repack</id>
                    <phase>package</phase>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                mywar 
                                <type>war</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>${project.build.directory}/classes/static/</outputDirectory>
                                <includes>**/*</includes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

我知道这是因为update-schema使用scripts / updateSchema.js - &gt; data / schema.js - &gt;从data / database.js(database.ts的编译版本)导入对象有 -

System.register([], function (exports_1) {
^

ReferenceError: System is not defined
    at Object.<anonymous> (database.js:9:1)
    at Module._compile (module.js:410:26)
..

摘录1:

System.register([], function(exports_1) {

1 个答案:

答案 0 :(得分:0)

tsconfig.json

&#34; module&#34;:&#34; system&#34;,

将其更改为

&#34; module&#34;:&#34; umd&#34;,

并且有效。