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"
|
||||
}
|
||||
|
|
@ -1,8 +1,3 @@
|
|||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
moduleFileExtensions: ["js", "ts"],
|
||||
testMatch: ["**/src/**/*.test.ts"],
|
||||
transform: {
|
||||
"^.+\\.(ts|tsx)$": "ts-jest",
|
||||
},
|
||||
preset: "ts-jest/presets/js-with-babel-esm"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@
|
|||
"scripts": {
|
||||
"dev": "webpack watch --mode development",
|
||||
"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)\"",
|
||||
"version": "node version-bump.mjs"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"type": "commonjs",
|
||||
"license": "MIT",
|
||||
"prettier": {
|
||||
"trailingComma": "none",
|
||||
|
|
|
|||
|
|
@ -4,106 +4,113 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|||
const fs = require("fs-extra");
|
||||
|
||||
module.exports = (env, argv) => ({
|
||||
devtool: argv.mode === "development" ? "inline-source-map" : false,
|
||||
entry: {
|
||||
index: "./src/vault-link-plugin.ts"
|
||||
},
|
||||
watchOptions: {
|
||||
ignored: "**/node_modules"
|
||||
},
|
||||
externals: {
|
||||
obsidian: "commonjs obsidian"
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
module: true
|
||||
}
|
||||
})
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "styles.css"
|
||||
}),
|
||||
new (require("webpack").DefinePlugin)({
|
||||
__CURRENT_DATE__: Date.now()
|
||||
}),
|
||||
{
|
||||
apply: (compiler) => {
|
||||
if (argv.mode !== "development") {
|
||||
return;
|
||||
}
|
||||
devtool: argv.mode === "development" ? "inline-source-map" : false,
|
||||
entry: {
|
||||
index: "./src/vault-link-plugin.ts"
|
||||
},
|
||||
watchOptions: {
|
||||
ignored: "**/node_modules"
|
||||
},
|
||||
externals: {
|
||||
obsidian: "commonjs obsidian"
|
||||
},
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
module: true
|
||||
}
|
||||
})
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "styles.css"
|
||||
}),
|
||||
|
||||
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"
|
||||
];
|
||||
destinations.forEach((destination) => {
|
||||
fs.copy(source, destination)
|
||||
.then(() => console.log("Files copied successfully after build!"))
|
||||
.catch((err) => console.error("Error copying files:", err));
|
||||
new (require("webpack").DefinePlugin)({
|
||||
__CURRENT_DATE__: Date.now()
|
||||
}),
|
||||
{
|
||||
apply: (compiler) => {
|
||||
if (argv.mode !== "development") {
|
||||
return;
|
||||
}
|
||||
|
||||
fs.createFile(path.join(destination, ".hotreload"));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.json$/i,
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: "[name][ext]"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.scss$/i,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
"css-loader",
|
||||
"resolve-url-loader",
|
||||
{
|
||||
loader: "sass-loader",
|
||||
options: {
|
||||
sourceMap: true // required by resolve-url-loader
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: ["ts-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/,
|
||||
type: "asset/inline"
|
||||
}
|
||||
]
|
||||
},
|
||||
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: ""
|
||||
}
|
||||
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"
|
||||
];
|
||||
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"));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.json$/i,
|
||||
type: "asset/resource",
|
||||
generator: {
|
||||
filename: "[name][ext]"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.scss$/i,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
"css-loader",
|
||||
"resolve-url-loader",
|
||||
{
|
||||
loader: "sass-loader",
|
||||
options: {
|
||||
sourceMap: true // required by resolve-url-loader
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: ["ts-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/,
|
||||
type: "asset/inline"
|
||||
}
|
||||
]
|
||||
},
|
||||
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