lingL
Denoβ€’2y agoβ€’
3 replies
ling

Deno Fresh: TypeError: 'import', and 'export' cannot be outside of module

Deno Fresh:
// @deno-types="npm:@arcgis/core/interfaces.d.ts"
import config from "npm:@arcgis/core@4.29/config.js";
import Bookmarks from "npm:@arcgis/core@4.29/widgets/Bookmarks.js";
import Expand from "npm:@arcgis/core@4.29/widgets/Expand.js";
import MapView from "npm:@arcgis/core@4.29/views/MapView.js";
import WebMap from "npm:@arcgis/core@4.29/WebMap.js";

import { useEffect, useRef } from "preact/hooks";

export default function EsriMap() {
  const mapDiv = useRef(null);

  useEffect(() => {
    config.request.useIdentity = false;
    if (mapDiv.current) {
      /**
       * Initialize application
       */
      const webmap = new WebMap({
        portalItem: {
          id: "aa1d3f80270146208328cf66d022e09c",
        },
      });
      // ... the rest of the initialization code
  }, [mapDiv]);

  return <div className="mapDiv" ref={mapDiv}></div>;
}

I'm trying to use a mapping library ES module @arcgis/core, but it gives the following error. Am i missing a type definition or something else?:
deno fresh with @arcgis/core
error:
Task start deno run -A --watch=static/,routes/ dev.ts
Watcher Process started.
The manifest has been generated for 7 routes and 2 islands.
error: Uncaught (in promise) TypeError: 'import', and 'export' cannot be used outside of module code at file:///home/user/Documents/playground/fresh-deno/node_modules/.deno/@esri+calcite-components@2.6.0/nod
e_modules/@stencil/core/internal/client/index.js:24:1

  import { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';
  ~~~~~~
  const manifest = (await import(toFileUrl(join(dir, "fresh.gen.ts")).href))
                    ^
    at async dev (https://deno.land/x/fresh@1.6.8/src/dev/dev_command.ts:38:21)
    at async file:///home/user/Documents/playground/fresh-deno/dev.ts:8:1
Watcher Process failed. Restarting on file change...
Was this page helpful?