Skip to content

Commit

Permalink
Merge pull request #569 from hildjj/fix-567
Browse files Browse the repository at this point in the history
Fixes #567.  Use file: URLs to import ES6.
  • Loading branch information
hildjj authored Nov 19, 2024
2 parents ab20d80 + 5385d24 commit a13b72b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
21 changes: 8 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Released: TBD

### Bug fixes

- [#567](https://github.com/peggyjs/peggy/issues/567) Load config files and plugins correctly on Windows by using file: URIs in import().

### Documentation

4.1.0
Expand All @@ -23,23 +25,16 @@ Released: 2024-10-03

### New features

- [#477](https://github.com/peggyjs/peggy/issues/477) Option to output .d.ts
files next to .js from CLI.
- [#477](https://github.com/peggyjs/peggy/issues/477) Option to output .d.ts files next to .js from CLI.
- [#530](https://github.com/peggyjs/peggy/issues/531) Allow es6 plugins from CLI
- [#532](https://github.com/peggyjs/peggy/issues/532) Allow es6 options files
from the CLI
- [#532](https://github.com/peggyjs/peggy/issues/532) Allow es6 options files from the CLI

### Bug fixes

- [#531](https://github.com/peggyjs/peggy/issues/531) Clean up rollup hacks
from CLI code.
- [#514](https://github.com/peggyjs/peggy/issues/514) Allow execution of
the `peggy` binary on Windows by handling node runtime flags manually,
executing a sub-instance of node to actually run `peggy`.
- [#538](https://github.com/peggyjs/peggy/pull/509) Fixed error in TS types
for `peg$maxFailExpected` and `peg$maxFailPos`.
- [#551](https://github.com/peggyjs/peggy/pull/551) Moved to package-extract
instead of a custom script for version file generation.
- [#531](https://github.com/peggyjs/peggy/issues/531) Clean up rollup hacks from CLI code.
- [#514](https://github.com/peggyjs/peggy/issues/514) Allow execution of the `peggy` binary on Windows by handling node runtime flags manually, executing a sub-instance of node to actually run `peggy`.
- [#538](https://github.com/peggyjs/peggy/pull/509) Fixed error in TS types for `peg$maxFailExpected` and `peg$maxFailPos`.
- [#551](https://github.com/peggyjs/peggy/pull/551) Moved to package-extract instead of a custom script for version file generation.

4.0.3
-----
Expand Down
6 changes: 4 additions & 2 deletions bin/opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const fs = require("fs");
const path = require("path");
const { InvalidArgumentError } = require("commander");
const { isErrno, isER, replaceExt, select } = require("./utils.js");
const { pathToFileURL } = require("url");

const MODULE_FORMATS_WITH_DEPS = ["amd", "commonjs", "es", "umd"];
const MODULE_FORMATS_WITH_GLOBAL = ["globals", "umd"];
Expand Down Expand Up @@ -140,7 +141,8 @@ function addExtraOptionsJSON(cmd, json, source) {
async function loadConfig(cmd, val) {
if (/\.[cm]?js$/.test(val)) {
try {
const eOpts = await import(path.resolve(val));
const configURL = pathToFileURL(path.resolve(val)).toString();
const eOpts = await import(configURL);
addExtraOptions(cmd, eOpts.default, "extra-options-file");
} catch (error) {
isER(error);
Expand Down Expand Up @@ -171,7 +173,7 @@ async function loadPlugin(cmd, val) {

// If this is an absolute or relative path (not a module name)
const id = (path.isAbsolute(val) || /^\.\.?[/\\]/.test(val))
? path.resolve(val)
? pathToFileURL(path.resolve(val)).toString()
: val; // Otherwise, it's an NPM module

/** @type {PEG.Plugin=} */
Expand Down

0 comments on commit a13b72b

Please sign in to comment.