Skip to content

Browser Friendly Relative Imports with .js extension #3047

@bennypowers

Description

@bennypowers

All modern browsers (including firefox) support es modules, but there is not 'module resolver' on the web, which means that browsers require relative URLs for module files.

import foo from 'foo' // sad browser 😢
import bar from '../bar/bar.js' // happy browser 😃

For users that do not need a complicated (or any) build step, apollo-client should provide a browser-friendly package with relative imports. This can be mechanically prepared.

Intended outcome:
This Just Works:

<script type="module">
  import { ApolloClient } from '/node_modules/apollo-client/ApolloClient.js';
</script>

Actual outcome:

Chrome 64:

Uncaught TypeError: Failed to resolve module specifier "apollo-link". Relative references must start with either "/", "./", or "../".

How to reproduce the issue:

Same as Intended outcome

Version

  • apollo-client@2.2.5

Notes
I was unable to find a rollup plugin which would do this automatically, but I'm reasonably confident that such a plugin would not be hard to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions