Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SyntaxError: Cannot use import statement outside a module #2178

@wschaef

Description

@wschaef

Stencil version:

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
I'm using a lib named Elix (https://component.kitchen/elix) and it works for npm start.
But I get an ERROR on npm-test:

 SyntaxError: Cannot use import statement outside a module

      2 | import { Model, Data, Element, Relation } from '../../global/model/index';
      3 | import { MatchResults, RouterHistory } from '@stencil/router';
    > 4 | import 'elix/define/Tabs'
        | ^
      5 | 
      6 | 
      7 | @Component({

sformer.js:537:17)
      at ScriptTransformer.transform (xxxxxx/node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
      at Object.<anonymous> (src/components/app-home/app-home.tsx:4:1)

Expected behavior:
npm test doesn't fail

Steps to reproduce:
Create Stencil a default Project with "npm init stencil" and select app
Related code:

npm install elix

add to any of stencil component. E.g. app-home
import 'elix/define/Tabs'

run npm test

// insert any relevant code here

Other information:
I've searched throught stenciljs and jest documentation and tried to solve it by adding

  testing: {
    transformIgnorePatterns: ["/node_modules/", "/node_modules/elix/.*"]
  }

to stencil.config.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions