Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #567. Use file: URLs to import ES6. #569

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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