Fix Jest WASM tests
This commit is contained in:
parent
438caa96a6
commit
7e045caab1
4 changed files with 110 additions and 109 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"jest.jestCommandLine": "npx jest",
|
"jest.jestCommandLine": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest",
|
||||||
"jest.rootPath": "plugin"
|
"jest.rootPath": "plugin"
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,3 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
testEnvironment: "node",
|
preset: "ts-jest/presets/js-with-babel-esm"
|
||||||
moduleFileExtensions: ["js", "ts"],
|
|
||||||
testMatch: ["**/src/**/*.test.ts"],
|
|
||||||
transform: {
|
|
||||||
"^.+\\.(ts|tsx)$": "ts-jest",
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,12 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack watch --mode development",
|
"dev": "webpack watch --mode development",
|
||||||
"build": "webpack --mode production",
|
"build": "webpack --mode production",
|
||||||
"test": "jest",
|
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
|
||||||
"lint": "eslint --fix src && prettier --write \"src/**/*.(ts|scss|json|html)\"",
|
"lint": "eslint --fix src && prettier --write \"src/**/*.(ts|scss|json|html)\"",
|
||||||
"version": "node version-bump.mjs"
|
"version": "node version-bump.mjs"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"type": "commonjs",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"trailingComma": "none",
|
"trailingComma": "none",
|
||||||
|
|
|
||||||
|
|
@ -4,106 +4,113 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
|
|
||||||
module.exports = (env, argv) => ({
|
module.exports = (env, argv) => ({
|
||||||
devtool: argv.mode === "development" ? "inline-source-map" : false,
|
devtool: argv.mode === "development" ? "inline-source-map" : false,
|
||||||
entry: {
|
entry: {
|
||||||
index: "./src/vault-link-plugin.ts"
|
index: "./src/vault-link-plugin.ts"
|
||||||
},
|
},
|
||||||
watchOptions: {
|
watchOptions: {
|
||||||
ignored: "**/node_modules"
|
ignored: "**/node_modules"
|
||||||
},
|
},
|
||||||
externals: {
|
externals: {
|
||||||
obsidian: "commonjs obsidian"
|
obsidian: "commonjs obsidian"
|
||||||
},
|
},
|
||||||
optimization: {
|
optimization: {
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
terserOptions: {
|
terserOptions: {
|
||||||
module: true
|
module: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
filename: "styles.css"
|
filename: "styles.css"
|
||||||
}),
|
}),
|
||||||
new (require("webpack").DefinePlugin)({
|
|
||||||
__CURRENT_DATE__: Date.now()
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
apply: (compiler) => {
|
|
||||||
if (argv.mode !== "development") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
compiler.hooks.done.tap("Copy Files Plugin", (stats) => {
|
new (require("webpack").DefinePlugin)({
|
||||||
const source = path.resolve(__dirname, "dist");
|
__CURRENT_DATE__: Date.now()
|
||||||
const destinations = [
|
}),
|
||||||
"/mnt/c/Users/Andras/Desktop/test/test/.obsidian/plugins/my-plugin",
|
{
|
||||||
"/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin",
|
apply: (compiler) => {
|
||||||
"/home/andras/obsidian-test/.obsidian/plugins/my-plugin"
|
if (argv.mode !== "development") {
|
||||||
];
|
return;
|
||||||
destinations.forEach((destination) => {
|
}
|
||||||
fs.copy(source, destination)
|
|
||||||
.then(() => console.log("Files copied successfully after build!"))
|
|
||||||
.catch((err) => console.error("Error copying files:", err));
|
|
||||||
|
|
||||||
fs.createFile(path.join(destination, ".hotreload"));
|
compiler.hooks.done.tap("Copy Files Plugin", (stats) => {
|
||||||
});
|
const source = path.resolve(__dirname, "dist");
|
||||||
});
|
const destinations = [
|
||||||
}
|
"/mnt/c/Users/Andras/Desktop/test/test/.obsidian/plugins/my-plugin",
|
||||||
}
|
"/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin",
|
||||||
],
|
"/home/andras/obsidian-test/.obsidian/plugins/my-plugin"
|
||||||
module: {
|
];
|
||||||
rules: [
|
destinations.forEach((destination) => {
|
||||||
{
|
fs.copy(source, destination)
|
||||||
test: /\.json$/i,
|
.then(() =>
|
||||||
type: "asset/resource",
|
console.log(
|
||||||
generator: {
|
"Files copied successfully after build!"
|
||||||
filename: "[name][ext]"
|
)
|
||||||
}
|
)
|
||||||
},
|
.catch((err) =>
|
||||||
{
|
console.error("Error copying files:", err)
|
||||||
test: /\.scss$/i,
|
);
|
||||||
use: [
|
|
||||||
MiniCssExtractPlugin.loader,
|
fs.createFile(path.join(destination, ".hotreload"));
|
||||||
"css-loader",
|
});
|
||||||
"resolve-url-loader",
|
});
|
||||||
{
|
}
|
||||||
loader: "sass-loader",
|
}
|
||||||
options: {
|
],
|
||||||
sourceMap: true // required by resolve-url-loader
|
module: {
|
||||||
}
|
rules: [
|
||||||
}
|
{
|
||||||
]
|
test: /\.json$/i,
|
||||||
},
|
type: "asset/resource",
|
||||||
{
|
generator: {
|
||||||
test: /\.ts$/,
|
filename: "[name][ext]"
|
||||||
use: ["ts-loader"]
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.wasm$/,
|
test: /\.scss$/i,
|
||||||
type: "asset/inline"
|
use: [
|
||||||
}
|
MiniCssExtractPlugin.loader,
|
||||||
]
|
"css-loader",
|
||||||
},
|
"resolve-url-loader",
|
||||||
resolve: {
|
{
|
||||||
extensions: [
|
loader: "sass-loader",
|
||||||
".ts",
|
options: {
|
||||||
".js" // required for development
|
sourceMap: true // required by resolve-url-loader
|
||||||
],
|
}
|
||||||
alias: {
|
}
|
||||||
root: __dirname,
|
]
|
||||||
src: path.resolve(__dirname, "src")
|
},
|
||||||
}
|
{
|
||||||
},
|
test: /\.ts$/,
|
||||||
output: {
|
use: ["ts-loader"]
|
||||||
clean: true,
|
},
|
||||||
filename: "main.js",
|
{
|
||||||
library: {
|
test: /\.wasm$/,
|
||||||
type: "commonjs" // required for Obsidian
|
type: "asset/inline"
|
||||||
},
|
}
|
||||||
path: path.resolve(__dirname, "dist"),
|
]
|
||||||
publicPath: ""
|
},
|
||||||
}
|
resolve: {
|
||||||
|
extensions: [
|
||||||
|
".ts",
|
||||||
|
".js" // required for development
|
||||||
|
],
|
||||||
|
alias: {
|
||||||
|
root: __dirname,
|
||||||
|
src: path.resolve(__dirname, "src")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
clean: true,
|
||||||
|
filename: "main.js",
|
||||||
|
library: {
|
||||||
|
type: "commonjs" // required for Obsidian
|
||||||
|
},
|
||||||
|
path: path.resolve(__dirname, "dist"),
|
||||||
|
publicPath: ""
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue