Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): fix transitive module dependencies in unit tests (#2178) #2549

Merged

Conversation

chrisdarroch
Copy link
Contributor

This should resolve a few Cannot use import statement outside a module errors when spec files are run.

There's a slightly deeper problem here re: who decides what is a module. Both typescript and jest can be configured to accept different extensions as module types, but neither configuration is honoured by the stencil compiler when spec files are run. Perhaps a better fix would be to inspect the opts in this helper function to determine which extensions to add here.

Adding js to the list of files to compile may introduce potential slowness or problems, as more files will be run through the typescript compiler now.

@chrisdarroch
Copy link
Contributor Author

I'm happy to submit tests and/or make a more nuanced fix for this problem.

At the moment, I'm unable to get a development environment set up so that I can run the test suite successfully, as I'm getting the following errors:

> npm run test
> @stencil/core@1.15.0 test /Users/cdarroch/work/github/stencil
> jest

● Validation Error:

  Preset ./testing/jest-preset.js is invalid:

  The "id" argument must be of type string. Received type object
  TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object
> npm run build
> @stencil/core@1.15.0 build <checkoutdir>/stencil
> node scripts && npm run tsc.prod && npm run rollup.prod.ci


> @stencil/core@1.15.0 tsc.prod <checkoutdir>/stencil
> tsc


> @stencil/core@1.15.0 rollup.prod.ci <checkoutdir>/stencil
> rollup --config --config-prod --config-ci

[!] Entry module not found: Error: Can't resolve '<checkoutdir>/stencil/src/sys/node/bundles/glob.js' in '<checkoutdir>/stencil'
resolve '<checkoutdir>/stencil/src/sys/node/bundles/glob.js' in '<checkoutdir>/stencil'
  using description file: <checkoutdir>/stencil/package.json (relative path: .)
    using description file: <checkoutdir>/stencil/package.json (relative path: ./src/sys/node/bundles/glob.js)
      no extension
        <checkoutdir>/stencil/src/sys/node/bundles/glob.js doesn't exist
      .wasm
        <checkoutdir>/stencil/src/sys/node/bundles/glob.js.wasm doesn't exist
      .mjs
        <checkoutdir>/stencil/src/sys/node/bundles/glob.js.mjs doesn't exist
      .js
        <checkoutdir>/stencil/src/sys/node/bundles/glob.js.js doesn't exist
      .json
        <checkoutdir>/stencil/src/sys/node/bundles/glob.js.json doesn't exist
      as directory
        <checkoutdir>/stencil/src/sys/node/bundles/glob.js doesn't exist

I also could not spot a sub-module responsible for testing the testing package... could you point that out to me?

@manucorporat manucorporat merged commit 6585dd1 into ionic-team:master Jul 4, 2020
@manucorporat
Copy link
Contributor

Thanks for your PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants