Re: What's up with "import declarations may only appear at top level of a module"
Kent Williams <[email protected]> Mon, 18 Jun 2018 08:54:53 -0500
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
OH and there's nothing about CompileModule in the SpiderMonkey API documentation. On 06/13/2018 11:00 AM, Jan de Mooij wrote: > You're probably trying to compile/execute the script as a plain script > instead of a module. See JS::CompileModule. There's also support for > modules in the JS shell (-m module I think), you could look at that as > well. > > Also, you might want to consider upgrading to ESR 60, its module > support is likely a lot better than what's in 52. > > Hope this helps, > Jan > > On Tue, Jun 12, 2018 at 3:05 PM, Kent Williams <[email protected] > <mailto:[email protected]>> wrote: > > So SpiderMonkey 52 supports ES6, and we're embedding the > TypeScript compiler. I got that part working but I get an error > compiling the compiled scripts. > > "compilation exception: import declarations may only appear at top > level of a module: file: , line: 1" > > This is my test program: > > import Add from "./TSTest2"; > let x:string='Hello from Typscript\n'; > > print_doc(x + Add(2,2).toString() + '\n'); > // cause_an_error; > > And this is the module it's trying to import: > > export default function Add(x: number, y:number): number { > return x + y; > } > > When I google that error message, all the references to <script> > tags in client side JS. How do I get a server-side SpiderMonkey > interpreter to not throw that error. > > > _______________________________________________ > dev-tech-js-engine mailing list > [email protected] > <mailto:[email protected]> > https://lists.mozilla.org/listinfo/dev-tech-js-engine > <https://lists.mozilla.org/listinfo/dev-tech-js-engine> > > _______________________________________________ dev-tech-js-engine mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine