Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

How to use the UMD version in a webpack environment? #87

Open
riddla opened this issue Feb 14, 2020 · 2 comments
Open

How to use the UMD version in a webpack environment? #87

riddla opened this issue Feb 14, 2020 · 2 comments

Comments

@riddla
Copy link

riddla commented Feb 14, 2020

Hello there.

I'm trying to import the UMD version in a Vue project that is based on webpack respectively https://laravel.com/docs/6.x/mix. It ends up in the following error message:

netlify:15357 Uncaught Error: Module parse failed: Unexpected token (11:6)
You may need an appropriate loader to handle this file type.
|   if (isBinaryBody(parameters)) {
|     return {
|       ...opts,
|       body: bodyA,
|       headers: { 'Content-Type': 'application/octet-stream', ...opts.headers }

I'm trying to use it as follows:

import { NetlifyAPI } from "netlify";
const client = new NetlifyAPI(
  "[api_key]"
);

Did anybody have success with the webpack/UMD combination?

@ehmicky
Copy link
Contributor

ehmicky commented Feb 14, 2020

Hi @riddla

UMD builds are currently experimental and are unfortunately not working quite yet.

In your case, it seems like Webpack might be tripping up on the ... spread operator. Maybe this is because you are targeting browsers that do not support that operator? Or because you are not using Babel?

@callmeaponte
Copy link

+1

I'm experiencing this same issue with Vue (technically a Nuxt app). If it helps for troubleshooting purposes - you can reproduce by creating a new Nuxt project, and then add the sample code (anywhere) provided in your README.

After that, when you attempt to start up the application via yarn dev - you'll be greeted with a Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. error.

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

No branches or pull requests

3 participants