I have a project set up, that uses Typescript
and RequireJS
to load the dependencies. I fail to get the wijmo.grid
dependecy to work.
I started with the Quickstart manual from Grapecity and adjusted it into my combination of Typescript & RequireJs.
This is what I want to do in test.ts
:
import { FlexGrid} from '@grapecity/wijmo.grid';
export class TestViewModel {
constructor() {
let grid = new FlexGrid('#hostElement');
}
}
The script tags:
<script src="~/lib/requirejs/require.js"></script>
<script src="~/js/require-config.js"></script>
<script>
require(
["my-test"],
function (myTest) {
var viewModel = new myTest.TestViewModel();
}
);
</script>
This is my require-config.ts
:
declare var require: any;
require.config({
baseUrl: "/",
paths: {
"jquery": [
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery",
"lib/jquery/dist/jquery-3.4.1"
],
"knockout": [
"https://cdnjs.cloudflare.com/ajax/libs/knockout/3.5.0/knockout-debug",
"lib/knockout/knockout-3.5.0.debug"
],
"@grapecity/wijmo.grid": [
"lib/@grapecity/wijmo.grid/es5-esm"
],
"my-test": "js/test"
},
waitSeconds: 15
});
This is my tsconfig.json
:
{
"compileOnSave": true,
"compilerOptions": {
"strict": true,
"noEmitOnError": true,
"sourceMap": true,
"removeComments": false,
"target": "es5",
"outDir": "wwwroot/js/",
"module": "amd",
"moduleResolution": "node",
"lib": [
"es6",
"dom"
]
},
"exclude": [
"wwwroot"
]
}
Now when I access that page, I expect it to work, but I get an error:
SyntaxError: import declarations may only appear at top level of a module (es5-esm.js:14:365)
What am I doing wrong here?
Edit:
I also tried using the index-module in require-config.ts
:
"@grapecity/wijmo.grid": [
"lib/@grapecity/wijmo.grid/index"
],
This leads to a different error:
ReferenceError: exports is not defined (index.js:14:379)
It seems like the wijmo modules are build targeting other module loaders than stated, or I am still missing some configuration.