GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Align require with node's require · Issue #4 · webpack/webpack

Align require with node's require #4

New issue
Copy link
New issue
Copy link
Closed
Closed
Align require with node's require#4
Copy link

Description

@jhnns
jhnns
opened on Jul 4, 2012
Issue body actions

For compatibility reasons modules-webpack's require should provide the same API as node's require. Especially the cache-object can be very useful (e.g. for unit tests).

Activity

  1. jhnns commented on Jul 4, 2012

    @jhnns
    jhnns
    on Jul 4, 2012
    ContributorAuthor
    More actions

    I'm not quite sure about require.resolve() but you could resolve the path while bundling and replace the relative path within the brackets with the (sanitized) absolute path (like you're doing it with require) (#5). The resolve function in the browser is a simple pass-through function that returns the passed path. This way I could easily remove a module from cache.

    Imagine this code:

    var modulePath = require.resolve("myModule/lib/test.js");
    
    delete require.cache[modulePath];
  2. sokra commented on Jul 4, 2012

    @sokra
    sokra
    on Jul 4, 2012
    Member
    More actions

    I think the most useful thing is to return the "id" (a number) from require.resolve because it's the only thing the browser should know. require.cache uses the module number as key.

    While compiling I replace the require.resolve call with a module id and the already existing cache object is exposed as require.cache.

  3. sokra
    closed this as completedin 3b219e3on Jul 4, 2012
  4. sokra commented on Jul 4, 2012

    @sokra
    sokra
    on Jul 4, 2012
    Member
    More actions

    done

  5. connorjclark
    added a commit that references this issue on Jan 28, 2018

    Merge pull request webpack#4 from lnwdr/feat-add-build-at

    635d659
  6. alexander-akait
    added a commit that references this issue on May 12, 2026

    feat: add `pure` parser option for css/module and css/auto

    b2fea1e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.