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

Publish ES module #192

Closed
znck opened this issue Aug 19, 2020 · 8 comments · Fixed by #455
Closed

Publish ES module #192

znck opened this issue Aug 19, 2020 · 8 comments · Fixed by #455

Comments

@znck
Copy link

znck commented Aug 19, 2020

Vite does not work well with commonjs module. In this case all named exports are inaccessible in vite build.

@Zippersk
Copy link

Zippersk commented Sep 8, 2020

I think we would also need to fix cross-fetch to get graphql-request working in Vite.

@justinfagnani
Copy link

I just tried to use graphql-request with a @web/dev-server and it doesn't work because it's not published as modules.

@alber70g
Copy link

alber70g commented Jan 20, 2021

@justinfagnani same here. Did you find a solution for this?

@alber70g
Copy link

As for @web/dev-server I'm using the rollup plugin commonjs. This fixes the exports for now, but it doesn't work yet.

web-dev-server now tries to resolve "util". I think it's because it's trying to resolve cross-fetch with node-fetch instead the browser variant?

+ import { fromRollup } from '@web/dev-server-rollup';
+ import commonjs from '@rollup/plugin-commonjs';
+ const rollupCommonjs = fromRollup(commonjs);

export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
  nodeResolve: true,
  open: '/',

  plugins: [
+     rollupCommonjs(),
  ],
});

@canonic-epicure
Copy link

Same here again. Any working solutions?

@canonic-epicure
Copy link

The workaround for me was to use esinstall to install graphql-request for me. It creates a separate folder web_modules and pulls in all dependencies. This is of course sub-optimal in regards of bundle size.

package.json

    "devDependencies": {
         "esinstall": "^1.1.7"
    }
}

web-install.js (any script name will work):

import { install } from 'esinstall'

await install([ 'graphql-request', 'graphql' ], { polyfillNode : true })

I'm also using @web/dev-server with the rollup's commonjs plugin. But it does not work for some reason.

@jasonkuhrt
Copy link
Member

Hey everyone, I'm interested in publishing a proper ESM soon, more info here #359.

@jasonkuhrt
Copy link
Member

I'm back on this now.

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