title: Cannot use import statement outside a module - but it is a module
body: <p>I have a web-app that depends on the <code>@arcgis/core</code>-package;</p>
  <pre><code>&quot;dependencies&quot;: {
      &quot;@arcgis/core&quot;: &quot;^4.23.7&quot;,
      &quot;@types/arcgis-js-api&quot;: &quot;^4.23.1&quot;,
      &quot;@vertigis/arcgis-extensions&quot;: &quot;^35.0.1&quot;,
      &quot;@vertigis/viewer-spec&quot;: &quot;47.6.0&quot;
  }
  </code></pre>
  <p>The package itself - from my understanding - also emits ES-modules, as it contains <code>&quot;type&quot;: &quot;module&quot;</code>:</p>
  <pre><code>{
    &quot;name&quot;: &quot;@arcgis/core&quot;,
    &quot;version&quot;: &quot;4.23.7&quot;,
    &quot;homepage&quot;: &quot;https://js.arcgis.com&quot;,
    ...
    &quot;dependencies&quot;: {
      &quot;@esri/arcgis-html-sanitizer&quot;: &quot;~2.9.0&quot;,
      &quot;@esri/calcite-colors&quot;: &quot;~6.0.1&quot;,
      &quot;@esri/calcite-components&quot;: &quot;1.0.0-beta.77&quot;,
      &quot;@popperjs/core&quot;: &quot;~2.11.4&quot;,
      &quot;focus-trap&quot;: &quot;~6.7.3&quot;,
      &quot;luxon&quot;: &quot;~2.3.1&quot;,
      &quot;sortablejs&quot;: &quot;~1.14.0&quot;
    },
    &quot;type&quot;: &quot;module&quot;
  }
  </code></pre>
  <p>When I run <code>npm build</code> everything is fine and I get a transpiled <code>main.js</code>-file within my <code>build</code>-directory.</p>
  <p>However when I try to exexute the code using <code>jest</code>, I get</p>
  <blockquote>
  <p>SyntaxError: Cannot use import statement outside a module</p>
  <pre><code>&gt; 1 | import FeatureLayer from &quot;@arcgis/core/layers/FeatureLayer&quot;;
      | ^
  </code></pre>
  </blockquote>
  <p>which I don't understand, as the package's type is set to <code>module</code> as shown above.</p>
  <p>My <code>jest.config.js</code> is this:</p>
  <pre><code>/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
  module.exports = {
    preset: 'ts-jest',
    testEnvironment: 'jsdom',
    transform: {   
      &quot;^.+\\.tsx?$&quot;: &quot;ts-jest&quot;    
    },
    transformIgnorePatterns: [
      &quot;node_modules/.*&quot;
    ]
  };
  </code></pre>
  <p>I also tried with <code>preset: 'ts-jest/presets/js-with-ts',</code> as suggested in <a href="https://stackoverflow.com/a/71545273/2528063">https://stackoverflow.com/a/71545273/2528063</a></p>