I use the browserify API to convert the code written in TypeScript into JavaScript and write the process of putting those codes together.
Below is the code that causes the problem.
(async()=>{
let code = wait (() = > {
const browserifyObject=browserify();
browserifyObject.add(`${__dirname}/game.js`);
return new Promise <string > ((resolve, reject) = > {
browserifyObject.bundle(error,source)=>{
if(error){
reject(error);
return;
}
const code = new TextDecoder().decode(source);
resolve(code);
});
});
})();
// a variety of treatments
})();
Error Log
[SyntaxError: 'import' and 'export' may appear only with 'sourceType:module'] {
line —1,
column: 1,
notated: '\n' +
(Omitted) \\node_modules\\three\\examples\\jsm\\controls\\OrbitControls.js:1\n
I understand that the error occurred because import
is used in JavaScript code in the file OrbitControls.js
in the 3D library Three.js, but I cannot find a way to resolve it and cannot proceed at all.
I set the sourceType
property to module
according to the instructions in the error content, but the error content did not change.Professor, please.
The browserify project itself is not working very well, so we decided to adopt a webpack that we have used only a little once.[From comments]
Thank you.
© 2024 OneMinuteCode. All rights reserved.