Repository: parcel-bundler/parcel
File: packages/resolvers/glob/src/GlobResolver.js (JavaScript)

Code before:
    if (sourceAssetType !== 'js' && sourceAssetType !== 'css') {
      error = `Glob imports are not supported in ${sourceAssetType} files.`;
    } else if (
      dependency.specifierType === 'url' &&
      !dependency.meta?.isCSSImport
    ) {
      error = 'Glob imports are not supported in URL dependencies.';
    }

    if (error) {
      throw errorToThrowableDiagnostic(error, dependency);
    }

    let invalidateOnFileCreate = [];
    let invalidateOnFileChange = new Set();

    switch (specifier[0]) {
      // Path specifier
      case '.': {
        specifier = path.resolve(path.dirname(sourceFile), specifier);
        break;
      }

      // Absolute path. Make the glob relative to the project root.
      case '/': {
        specifier = path.resolve(options.projectRoot, specifier.slice(1));
        break;
      }

      // Tilde path. Package relative. Resolve relative to nearest node_modules
      // directory, the nearest directory with package.json or the project
      // root - whichever comes first.
      case '~': {
        const insideNodeModules = options.projectRoot.includes('node_modules');
        let dir = path.dirname(sourceFile);

        while (
          dir !== options.projectRoot &&
          path.basename(path.dirname(dir)) !== 'node_modules' &&
          (insideNodeModules ||
            !(await options.inputFS.exists(path.join(dir, 'package.json'))))
        ) {
          dir = path.dirname(dir);

          if (dir === path.dirname(dir)) {
            dir = options.projectRoot;
            break;
          }
        }

        specifier = path.resolve(dir, specifier.slice(2));

Review comment (suggestion):
~~On Windows, this will rewrite slashes in the specifier into backslashes:~~ Which is fine for Parcel, apparently
```js
> path.posix.resolve("/src/app","dir") // default path.resolve on Unix
'/src/app/dir'
> path.win32.resolve("/src/app","dir") // default path.resolve on Windows
'\\src\\app\\dir'
```



Code after:
    if (sourceAssetType !== 'js' && sourceAssetType !== 'css') {
      error = `Glob imports are not supported in ${sourceAssetType} files.`;
    } else if (
      dependency.specifierType === 'url' &&
      !dependency.meta?.isCSSImport
    ) {
      error = 'Glob imports are not supported in URL dependencies.';
    }

    if (error) {
      throw errorToThrowableDiagnostic(error, dependency);
    }

    let invalidateOnFileCreate = [];
    let invalidateOnFileChange = new Set();

    switch (specifier[0]) {
      // Path specifier
      case '.': {
        specifier = path.resolve(path.dirname(sourceFile), specifier);
        break;
      }

      // Absolute path. Make the glob relative to the project root.
      case '/': {
        specifier = path.resolve(options.projectRoot, specifier.slice(1));
        break;
      }

      // Tilde path. Package relative. Resolve relative to nearest node_modules
      // directory, the nearest directory with package.json or the project
      // root - whichever comes first.
      case '~': {
        let dir = path.dirname(sourceFile);
        let pkgPath = nullthrows(
          options.inputFS.findAncestorFile(
            ['package.json'],
            dir,
            options.projectRoot,
          ),
        );
        specifier = path.resolve(path.dirname(pkgPath), specifier.slice(2));
        break;
      }

      // Support package-ish specifiers like:
      //   foo      (node_module)
      //   @foo/bar (scoped node_module)
      //
      // First we resolve the initial portion using NodeResolver, then we tack
      // on the remaining glob.