I have try the following structure in my angular project:
src
|- app
|- app.module.ts
|- assets
|- google
|- blockly
|- blockly_uncompressed.js
|- closure-library
I write code in app.module.ts:
import {Blockly} from '../assets/google/blockly/blockly_uncomressed';
When i ng serve, it show error:
ERROR in src/app/app.module.ts(35,23): error TS2307: Cannot find module '../assets/google/blockly/blockly_uncomressed'.
Or i try the other way to import:
require('../assets/google/blockly/blockly_uncomressed.js');
it show error:
Module not found: Error: Can't resolve '../assets/google/blockly/blockly_uncomressed.js' in ...
I checked the code at the head of `blockly_uncompressed.js`
this.IS_NODE_JS = !!(typeof module !== 'undefined' && module.exports);
this.BLOCKLY_DIR = (function(root) {
if (!root.IS_NODE_JS) {
// Find name of current directory.
var scripts = document.getElementsByTagName('script');
var re = new RegExp('(.+)[\/]blockly_(.*)uncompressed\.js$');
for (var i = 0, script; script = scripts[i]; i++) {
var match = re.exec(script.src);
if (match) {
return match[1];
}
}
alert('Could not detect Blockly\'s directory name.');
}
return '';
})(this);
Why it can't detect the nodejs? because this.IS_NODE_JS is false
Anyone can tell me how to develop blockly in angular / nodejs project? Thanks