Compare commits

..

No commits in common. "v0.1.0-develop.30" and "v0.1.0-develop.29" have entirely different histories.

7 changed files with 1391 additions and 1314 deletions

View File

@ -1 +0,0 @@
src/templates/vite.config.js

View File

@ -1,11 +1,3 @@
# [0.1.0-develop.30](https://git.lumeweb.com/LumeWeb/presetter-kernel-module-preset/compare/v0.1.0-develop.29...v0.1.0-develop.30) (2023-07-03)
### Bug Fixes
* change node-resolve config to assume it is an object entry since we rewrite it in the rollup plugin in browser mode ([398be8f](https://git.lumeweb.com/LumeWeb/presetter-kernel-module-preset/commit/398be8fede84167282c3252ab24e6149bf095f32))
* passing browser mode does not work here ([40580f7](https://git.lumeweb.com/LumeWeb/presetter-kernel-module-preset/commit/40580f793f7c4b94f37cf62961bd062b4bb24c55))
# [0.1.0-develop.29](https://git.lumeweb.com/LumeWeb/presetter-kernel-module-preset/compare/v0.1.0-develop.28...v0.1.0-develop.29) (2023-07-03) # [0.1.0-develop.29](https://git.lumeweb.com/LumeWeb/presetter-kernel-module-preset/compare/v0.1.0-develop.28...v0.1.0-develop.29) (2023-07-03)

2576
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,15 @@
{ {
"name": "@lumeweb/presetter-kernel-module-preset", "name": "@lumeweb/presetter-kernel-module-preset",
"version": "0.1.0-develop.30", "version": "0.1.0-develop.29",
"type": "module", "type": "module",
"main": "lib/index.js", "main": "lib/index.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/presetter-kernel-module-preset.git" "url": "gitea@git.lumeweb.com:LumeWeb/presetter-kernel-module-preset.git"
}, },
"devDependencies": {
"presetter": "*"
},
"readme": "ERROR: No README data found!", "readme": "ERROR: No README data found!",
"scripts": { "scripts": {
"prepare": "presetter bootstrap", "prepare": "presetter bootstrap",
@ -15,10 +18,7 @@
}, },
"dependencies": { "dependencies": {
"@lumeweb/node-library-preset": "0.2.7", "@lumeweb/node-library-preset": "0.2.7",
"presetter": "^4.0.1", "@lumeweb/presetter-preset-rollup": "4.1.0-develop.5"
"vite": "^4.4.2",
"vite-plugin-node-polyfills": "^0.9.0",
"vite-plugin-optimizer": "^1.4.2"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@ -1,50 +1,6 @@
import type { PresetAsset } from "presetter-types"; import type { PresetAsset } from "presetter-types";
import { PresetContext } from "presetter-types"; import { PresetContext } from "presetter-types";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { loadFile, resolveDirective, template } from "presetter";
const DIR = fileURLToPath(dirname(import.meta.url));
// paths to the template directory
const TEMPLATES = resolve(DIR, "..", "templates");
/** List of configurable variables */
export type Variable = {
/** the directory containing all source code (default: source) */
source: string;
/** the directory containing all the compiled files (default: lib) */
output: string;
buildSource: string;
};
export const DEFAULT_VARIABLE: Variable = {
source: "build",
output: "lib",
buildSource: "src",
};
function buildOptions(context: PresetContext) {
const opts = context.custom.config?.vite as any;
if (!opts) {
throw new Error("vite options missing!");
}
const build = opts.build;
const resolve = opts.resolve;
const optimize = opts.optimize;
const polyfill = opts.polyfill;
return {
viteBuild: resolveDirective(build, context).stringifiedConfig,
viteResolve: resolveDirective(resolve, context).stringifiedConfig,
viteOptimize: resolveDirective(optimize, context).stringifiedConfig,
vitePolyfill: resolveDirective(polyfill, context).stringifiedConfig,
};
}
/** /**
* get the list of templates provided by this preset * get the list of templates provided by this preset
* @returns list of preset templates * @returns list of preset templates
@ -55,42 +11,35 @@ export default async function (context: PresetContext): Promise<PresetAsset> {
: []; : [];
return { return {
extends: ["@lumeweb/node-library-preset"], extends: [
template: { "@lumeweb/node-library-preset",
/* eslint-disable @typescript-eslint/naming-convention */ "@lumeweb/presetter-preset-rollup",
"vite.config.js": (context) => { ],
const content = loadFile(resolve(TEMPLATES, "vite.config.js"), "text");
const variable = buildOptions(context);
return template(content, variable);
/* eslint-enable @typescript-eslint/naming-convention */
},
},
supplementaryIgnores: ignores, supplementaryIgnores: ignores,
supplementaryConfig: { supplementaryConfig: {
// @ts-ignore
browser: true,
release: { release: {
plugins: { plugins: {
"3": ["@semantic-release/npm", { npmPublish: false }], "3": ["@semantic-release/npm", { npmPublish: false }],
}, },
}, },
vite: { rollup: {
build: { plugins: {
outDir: "{output}", "1": [
lib: { "@apply @rollup/plugin-node-resolve[default]",
// Could also be a dictionary or array of multiple entry points [
entry: "{source}/index.js", {
name: "main", dedupe: [
formats: ["cjs"], "@lumeweb/libkernel",
fileName: "index", "@lumeweb/libweb",
}, "@lumeweb/libportal",
minify: false, ],
},
],
],
}, },
resolve: {},
optimize: {},
polyfill: {},
}, },
}, },
scripts: resolve(TEMPLATES, "scripts.yaml"),
variable: DEFAULT_VARIABLE,
}; };
} }

View File

@ -1,7 +0,0 @@
# replace the `prepare` template from presetter-preset
# so that the build procedure will not be triggered upon package installation
build: cross-env NODE_ENV=production run-s clean build:typescript:* build:vite
build:vite: vite build && mv lib/*.cjs lib/index.js
develop: cross-env NODE_ENV=development run-s "vite:rollup -- --watch {@}" --
clean:buildOutput: shx rm -rf {source}

View File

@ -1,12 +0,0 @@
import { defineConfig } from "vite";
import path from "path";
import optimizer from "vite-plugin-optimizer";
import { nodePolyfills } from "vite-plugin-node-polyfills";
export default defineConfig({
build: {viteBuild},
resolve: {viteResolve},
plugins: [
optimizer({viteOptimize}),
nodePolyfills({vitePolyfill}),
],
});