malinajs 0.7.1-alpha → 0.7.2-a10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/malina-esbuild.js +19 -10
- package/malina.js +6458 -5764
- package/package.json +7 -5
- package/readme.md +13 -7
- package/runtime.js +1081 -870
- package/CHANGELOG.md +0 -58
package/malina-esbuild.js
CHANGED
|
@@ -11,11 +11,9 @@ process.argv.includes('-w') ? process.env.WATCH = 1 : null;
|
|
|
11
11
|
|
|
12
12
|
const esbuildConfigPath = path.join(process.cwd(),'esbuild.config.js');
|
|
13
13
|
const derverConfigPath = path.join(process.cwd(),'derver.config.js');
|
|
14
|
-
const malinaConfigPath = path.join(process.cwd(),'malina.config.js');
|
|
15
14
|
|
|
16
15
|
const esbuildConfig = fs.existsSync(esbuildConfigPath) ? require(esbuildConfigPath) : {};
|
|
17
16
|
const derverConfig = fs.existsSync(derverConfigPath) ? require(derverConfigPath) : {};
|
|
18
|
-
const malinaConfig = fs.existsSync(malinaConfigPath) ? require(malinaConfigPath) : {};
|
|
19
17
|
|
|
20
18
|
// Executable
|
|
21
19
|
|
|
@@ -60,16 +58,26 @@ function malinaPlugin(options={}){
|
|
|
60
58
|
|
|
61
59
|
const cssModules = new Map();
|
|
62
60
|
|
|
63
|
-
options = {
|
|
64
|
-
...malinaConfig,
|
|
65
|
-
...options
|
|
66
|
-
}
|
|
67
|
-
|
|
68
61
|
if(options.displayVersion !== false) console.log('! Malina.js', malina.version);
|
|
69
|
-
|
|
62
|
+
|
|
70
63
|
return {
|
|
71
64
|
name: 'malina-plugin',
|
|
72
|
-
setup(build) {
|
|
65
|
+
setup(build) {
|
|
66
|
+
build.onResolve({ filter: /^malinajs$/ }, async (args) => {
|
|
67
|
+
const runtime = await build.resolve('malinajs/runtime.js', {resolveDir: args.resolveDir});
|
|
68
|
+
return {
|
|
69
|
+
path: runtime.path,
|
|
70
|
+
sideEffects: false
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
build.onResolve({ filter: /\.(xht|ma|html)$/ }, (arg) => {
|
|
75
|
+
return {
|
|
76
|
+
path: path.resolve(arg.resolveDir,arg.path),
|
|
77
|
+
sideEffects: false
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
73
81
|
build.onLoad(
|
|
74
82
|
{ filter: /\.(xht|ma|html)$/ },
|
|
75
83
|
async (args) => {
|
|
@@ -77,13 +85,14 @@ function malinaPlugin(options={}){
|
|
|
77
85
|
let source = await fsp.readFile(args.path, 'utf8');
|
|
78
86
|
|
|
79
87
|
let ctx = await malina.compile(source,{
|
|
88
|
+
path: args.path,
|
|
80
89
|
name: args.path.match(/([^/\\]+)\.\w+$/)[1],
|
|
81
90
|
...options
|
|
82
91
|
});
|
|
83
92
|
|
|
84
93
|
let code = ctx.result;
|
|
85
94
|
|
|
86
|
-
if(
|
|
95
|
+
if(ctx.css.result){
|
|
87
96
|
const cssPath = args.path.replace(/\.\w+$/, ".malina.css").replace(/\\/g, "/");
|
|
88
97
|
cssModules.set(cssPath,ctx.css.result);
|
|
89
98
|
code += `\nimport "${cssPath}";`
|