Skip to content
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

33 changes: 0 additions & 33 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [22.x, 24.x]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To contribute code, see the following steps,
`git clone https://github.com/<your-username>/pyodide-webpack-plugin.git`\
and add the upstream remote,\
`git remote add upstream https://github.com/pyodide/pyodide-webpack-plugin.git`
3. Nodejs [18.x+](https://nodejs.org/en/)
3. Nodejs [22.x or 24.x](https://nodejs.org/en/)
4. Install requirements\
`npm i`
5. See Testing and benchmarking documentation.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ A Webpack plugin for integrating pyodide into your project.

> works with pyodide >=0.21.3

For versions of Pyodide older than 0.28.0 please use @pyodide/pyodide-webpack-plugin@1.3.3 or older.

## Getting Started

Install pyodide and @pyodide/webpack-plugin
Expand Down Expand Up @@ -46,7 +48,7 @@ async function main() {
pyodide.runPython(`
import sys
sys.version
`)
`),
);
}
main();
Expand Down
49 changes: 49 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Changelog

# [1.1.0] - 2023-11-01

### Added

Support for additional configurations.

### Changed

Refactored code for better readability.

### Fixed

Addressed issues reported by users.

# [1.0.1] - 2023-10-15

### Fixed

Minor bug fixes and performance improvements.

# [1.0.0] - 2023-10-01

### Added

Initial release of the pyodide-webpack-plugin.

### Changed

Documentation improvements.

### Fixed

Resolved issues with compatibility.

# [Unreleased]

### Added

New feature to enhance performance.

### Changed

Updated dependencies to the latest versions.

### Fixed

Bug fixes for improved stability.
42 changes: 42 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import tseslint from "@typescript-eslint/eslint-plugin";
import tsparser from "@typescript-eslint/parser";
import prettierPlugin from "eslint-plugin-prettier";
import prettierConfig from "eslint-config-prettier";

export default [
{ ignores: ["node_modules/", "dist/"] },
{
files: ["**/*.{ts, js}"],
languageOptions: {
parser: tsparser,
sourceType: "module",
globals: {
describe: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
it: "readonly",
},
},

plugins: {
"@typescript-eslint": tseslint,
prettier: prettierPlugin,
},

rules: {
...tseslint.configs.recommended.rules,
...prettierConfig.rules,
"no-constant-condition": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_{1,}$",
varsIgnorePattern: "^_{1,}$",
caughtErrorsIgnorePattern: "^_{1,}$",
},
],
"@typescript-eslint/ban-ts-comment": 0,
},
},
];
2 changes: 1 addition & 1 deletion examples/commonjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function main() {
pyodide.runPython(`
import sys
sys.version
`)
`),
);
}
main();
8 changes: 4 additions & 4 deletions examples/commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@pyodide/webpack-plugin": "^1.3.1",
"@pyodide/webpack-plugin": "^1.2.0",
"html-webpack-plugin": "^5.5.3",
"webpack": "5.88.x",
"webpack": "^5.101.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "4.14.x"
"webpack-dev-server": "^5.2.2"
},
"dependencies": {
"pyodide": "^0.24.1"
"pyodide": "^0.28.0"
},
"description": ""
}
2 changes: 1 addition & 1 deletion examples/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function main() {
pyodide.runPython(`
import sys
sys.version
`)
`),
);
}
main();
8 changes: 4 additions & 4 deletions examples/esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@pyodide/webpack-plugin": "^1.3.1",
"@pyodide/webpack-plugin": "^1.2.0",
"html-webpack-plugin": "^5.5.3",
"webpack": "5.88.x",
"webpack": "^5.101.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "4.14.x"
"webpack-dev-server": "^5.2.2"
},
"dependencies": {
"pyodide": "^0.24.1"
"pyodide": "^0.28.0"
},
"description": ""
}
13 changes: 8 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class PyodidePlugin extends CopyPlugin {
* @param pyodidePath
* @returns
*/
function tryGetPyodidePath(pyodidePath?: string) {
function tryGetPyodidePath(pyodidePath?: string): string {
if (pyodidePath) {
return path.resolve(pyodidePath);
}
Expand All @@ -135,15 +135,15 @@ function tryGetPyodidePath(pyodidePath?: string) {
noop(e);
}
}
const walk = (p: string) => {
const walk = (p: string): string => {
const stat = fs.statSync(p);
if (stat.isFile()) {
return walk(path.dirname(p));
}
if (stat.isDirectory()) {
if (path.basename(p) === "node_modules") {
throw new Error(
"unable to locate pyodide package. You can define it manually with pyodidePath if you're trying to test something novel"
"unable to locate pyodide package. You can define it manually with pyodidePath if you're trying to test something novel",
);
}
for (const dirent of fs.readdirSync(p, { withFileTypes: true })) {
Expand All @@ -159,12 +159,15 @@ function tryGetPyodidePath(pyodidePath?: string) {
}
} catch (e) {
throw new Error(
"unable to locate and parse pyodide package.json. You can define it manually with pyodidePath if you're trying to test something novel"
`unable to locate and parse pyodide package.json. You can define it manually with pyodidePath if you're trying to test something novel. ${(e as Error).message}`,
);
}
}
return walk(path.dirname(p));
}
throw new Error(
"unable to locate pyodide package. You can define it manually with pyodidePath if you're trying to test something novel",
);
};
return walk(pyodideEntrypoint);
}
Expand All @@ -183,7 +186,7 @@ function tryResolvePyodidePackage(pyodidePath: string, version?: string) {
const pkg = fs.readFileSync(pkgPath, "utf-8");
return JSON.parse(pkg);
} catch (e) {
throw new Error(`unable to read package.json from pyodide dependency in ${pkgPath}`);
throw new Error(`unable to read package.json from pyodide dependency in ${pkgPath}. ${(e as Error).message}`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Parser as AcornParser, Node } from "acorn";
import { importAssertions } from "acorn-import-assertions";
import esbuild from "esbuild";
import { LoaderContext } from "webpack";
const walk = require("acorn-walk");
const walk = require("acorn-walk"); // eslint-disable-line
const parser = AcornParser.extend(importAssertions as typeof importAssertions);

interface LoaderOptions {
Expand All @@ -18,7 +18,7 @@ class PyodideParser {
constructor(source: string, options: LoaderOptions) {
this.delta = 0;
this.ast = parser.parse(source, {
ecmaVersion: 2020,
ecmaVersion: 2025,
sourceType: options.isModule ? "module" : "script",
});
this.options = options;
Expand Down
Loading