Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #6952
Closed
Open
Issue created Apr 30, 2019 by Administrator@rootContributor

Allow import of built-in browser modules, i.e. std:kv-storage

Created by: andria-dev

Should built-in browser modules be supported?

As it currently stands, CRA does not support built-in, standard library, browser modules and I haven't been able to find any information or discussion on future support for these modules (i.e. std:kv-storage).

If built-in modules are to ever be supported it would make sense to use polyfills as fallbacks. CRA could handle polyfilling those modules itself or allow developers to provide a mapping of built-in module names to fallbacks (i.e. a URL or a module in node_modules/).

Is this a bug report?

Yes

Environment

Browser: Chrome v74 (you'll need this to import std:kv-storage) Dev Environment: Codesandbox but the problem is everywhere CRA version: 3.0.0

Steps to Reproduce

  1. Enable experimental web platform features on Chrome chrome://flags/#enable-experimental-web-platform-features
  2. Create a new project with CRA
  3. Attempt to import storage from std:kv-storage inside any js file (I used /src/index.js) like so:
import { storage } from 'std:kv-storage';
  1. Try to console.log the imported storage variable.
console.log(storage);

Expected Behavior

I expected the build to succeed by being able to identify that this import was referencing a built-in module because it was prefixed with std:, and, therefore, not attempt to find and bundle a module called std:kv-storage from /node_modules/.

Since it didn't build the application, this part never happened but I expected the console.log(storage) log the following to the console:

StorageArea {}

Actual Behavior

The build fails with the error:

Module not found: Can't resolve 'std:kv-storage'

Reproducible Demo

CRA unsuccessful build repro: https://codesandbox.io/s/4lw89q0l14?fontsize=14

Static example of importing std:kv-storage: https://codesandbox.io/s/7m87rjjk90?fontsize=14

Assignee
Assign to
Time tracking