ProjectEvergreen / greenwood

Greenwood is your full-stack workbench for the web, focused on supporting modern web standards and development to help you create your next project.
https://www.greenwoodjs.io
MIT License
95 stars 9 forks source link

custom loader hook not handling bare specifiers when resolve URLs (`invalid URL`) #1161

Closed thescientist13 closed 9 months ago

thescientist13 commented 9 months ago

Type of Change

Bug

Summary

Noticed as part of https://github.com/thescientist13/greenwood-htmx/pull/7 that I was getting an invalid URL error, seemingly an error with bare specifiers?

➜  greenwood-htmx git:(import-css) yarn build
yarn run v1.22.19
$ node --experimental-loader ./node_modules/@greenwood/cli/src/loader.js ./node_modules/.bin/greenwood build
(node:81536) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
{
  specifier: 'file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/index.js',
  context: {
    conditions: [ 'node', 'import', 'node-addons' ],
    importAssertions: [Object: null prototype] {},
    parentURL: undefined
  },
  parentURL: undefined
}
{
  specifier: './lifecycles/compile.js',
  context: {
    conditions: [ 'node', 'import', 'node-addons' ],
    importAssertions: [Object: null prototype] {},
    parentURL: 'file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/index.js'
  },
  parentURL: 'file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/index.js'
}
{
  specifier: 'fs/promises',
  context: {
    conditions: [ 'node', 'import', 'node-addons' ],
    importAssertions: [Object: null prototype] {},
    parentURL: 'file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/index.js'
  },
  parentURL: 'file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/index.js'
}
{
  specifier: 'commander',
  context: {
    conditions: [ 'node', 'import', 'node-addons' ],
    importAssertions: [Object: null prototype] {},
    parentURL: 'file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/index.js'
  },
  parentURL: 'file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/index.js'
}
node:internal/errors:484
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:393:5)
    at URL.onParseError (node:internal/url:565:9)
    at new URL (node:internal/url:645:5)
    at resolve (file:///Users/owenbuckley/Workspace/github/greenwood-htmx/node_modules/@greenwood/cli/src/loader.js:55:58)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  input: './lifecycles/compile.js',
  code: 'ERR_INVALID_URL'
}

Node.js v18.12.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Details

Not sure if this just the first time hitting this use case, but surprised only seeing it now.

Going to release this agains the v0.29.0 alpha release branch