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

[BUG] Babel-plugin bug on imports with comments #3370

Open
4 tasks done
alubbe opened this issue May 26, 2021 · 2 comments
Open
4 tasks done

[BUG] Babel-plugin bug on imports with comments #3370

alubbe opened this issue May 26, 2021 · 2 comments

Comments

@alubbe
Copy link

alubbe commented May 26, 2021

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager npm (Fill in: npm, yarn, pnpm, etc).
  • I run Snowpack on OS Mac (Fill in: Windows, Mac, Linux, etc).
  • I run Snowpack on Node.js v14 (bug also exists on 16)

Describe the bug

When using the '@snowpack/plugin-babel', plugin, we cannot import this:

import * as am4charts from '@amcharts/amcharts4/charts';

because snowpack dev throws this error:

Cannot find module '
          /* webpackChunkName: "pdfmake" */
          'pdfmake/build/pdfmake.js'' from '/snowpack-babel-import/node_modules/@amcharts/amcharts4/charts.js'

It compiles just fine when disabling the babel plugin.

To Reproduce

  1. Clone https://github.com/alubbe/snowpack-babel-import
  2. npm install
  3. npm start to see the error
  4. Remove or comment out '@snowpack/plugin-babel' from snowpack.config.js
  5. npm start now works

Ideas

Interestingly, doing things like this in our index.jsx compiles just fine

import(/* webpackChunkName: "pdfmake" */ "pdfmake/build/pdfmake.js"),

import(
  /* webpackChunkName: "books" */
  'react');

and also snowpack build also works fine.

Googling around I found these two pieces of information, which might help understand what's going on:
https://www.amcharts.com/docs/v4/getting-started/integrations/using-webpack/
webpack/webpack#8656

Let me know if there's anything else I can help with here!

@alubbe
Copy link
Author

alubbe commented Jun 7, 2021

I know you're all incredibly busy, but here's a gentle poke to see if anyone has an idea what could be causing this issue - happy to help brain storm a solution!

From the fact that snowpack dev is affected while snowpack build works just fine, it might be a rollup configuration difference?

@tom-sherman
Copy link

tom-sherman commented Jul 10, 2021

I've ran into a similar issue when using react-syntax-highlighter. Stack trace below

Error: Cannot find module '
    /* webpackChunkName: "react-syntax-highlighter_languages_highlight_oneC" */
    'highlight.js/lib/languages/1c'' from '~/node_modules/react-syntax-highlighter/dist/esm/index.js'
    at Function.resolveSync [as sync] (~/node_modules/resolve/lib/sync.js:102:15)
    at Object.resolveEntrypoint (~/node_modules/snowpack/lib/index.js:97684:59)
    at PackageSourceLocal.buildPackageImport (~/node_modules/snowpack/lib/index.js:124589:34)
    at async ~/node_modules/snowpack/lib/index.js:124749:21
    at async PackageSourceLocal.buildPackageImport (~/node_modules/snowpack/lib/index.js:124616:30)
    at async ~/node_modules/snowpack/lib/index.js:124749:21
    at async PackageSourceLocal.buildPackageImport (~/node_modules/snowpack/lib/index.js:124616:30)
    at async PackageSourceLocal.prepare (~/node_modules/snowpack/lib/index.js:124392:13)
    at async Object.command (~/node_modules/snowpack/lib/index.js:125207:5)
    at async cli (~/node_modules/snowpack/lib/index.js:178039:9)

Not using the babel plugin though, used the typescript react template.

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

No branches or pull requests

2 participants