Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
614dd4f
❄️🔁: implement preliminary support for babel transforms
merryman Feb 24, 2025
f46775b
🔁: fix typo in export all source transform
merryman Mar 5, 2025
0d604fd
🔁❄️: use babel parse in the bundler specific transforms
merryman Mar 5, 2025
5ef59c8
🔁🧑‍🏫❄️: expose babel class transform via classes index
merryman Mar 5, 2025
1798449
🌳: extract handleExportStmt()
merryman Mar 5, 2025
ed6a2a8
🧑‍🏫: make class transform immunte to frozen prototypes
merryman Mar 5, 2025
b962420
❄️: add missing module source caching
merryman Mar 5, 2025
8307e7f
❄️: remove promise from normalizeFileName
merryman Mar 5, 2025
66f7a71
❄️: clear pending asyncs
merryman Mar 5, 2025
a8bf37d
❄️: fix !cjs in chunkname to cause loading issues
merryman Mar 5, 2025
2e70179
🔁: fix errors in bundle specific source transforms
merryman Mar 5, 2025
3cf3732
🔁❄️: export babel nodes and getScopeFromPath
merryman Mar 5, 2025
f9bed32
❄️: enable sourcemaps in freezer scripts
merryman Mar 5, 2025
019d381
❄️: fix extraction of default exports from frozen records
merryman Mar 5, 2025
446cfa1
❄️: fix binding of this in inline traverse of babel plugins
merryman Mar 5, 2025
076d5af
❄️: generate nodes with proper babel types
merryman Mar 5, 2025
4cc8768
❄️: fix esm url handling in transform options generation
merryman Mar 6, 2025
f8d474b
❄️: fix invocation of babel transforms in bundler
merryman Mar 6, 2025
6fd3480
❄️: add sourcemap config option to lively plugin
merryman Mar 6, 2025
5161396
🧩: fix import map retrieval for nested esm imports
merryman Mar 10, 2025
c104077
🔁: refrain from using babel.parse to replace import-exports
merryman Mar 11, 2025
2475bf3
🔁: fix bugs in the babel source transforms
merryman Mar 11, 2025
2a26b89
❄️: only use babel is source map is desired
merryman Mar 11, 2025
b6c53fa
❄️🔁: avoid babel prettyfier for better performance
merryman Mar 11, 2025
23e73c3
❄️: do not create source-maps on CI runs
merryman Mar 11, 2025
20a7ed6
❄️: fix non sourcemap build
merryman Mar 11, 2025
e56837c
❄️📦: control source map builds via custom DEBUG flag
merryman Mar 11, 2025
b525298
🔁: fix typos
merryman Mar 11, 2025
c5fe180
📙: remove this reference from interval code
merryman Mar 12, 2025
8887338
🧑‍🏫🔁: fix class and capturing transform tests
merryman Mar 12, 2025
802c53f
🔁: fix increment for tmp var generation
merryman Mar 12, 2025
a31c2c6
🔁: do not apply compact babel transform for lively module transform
merryman Mar 12, 2025
26cf4e6
🫓: update flatn
merryman Mar 12, 2025
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
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ landing-page:
rm -rf lively.freezer/landing-page
env CI=true npm --prefix lively.freezer run build-landing-page

landing-page-debug:
rm -rf lively.server/.module_cache
rm -rf lively.freezer/landing-page
env CI=true DEBUG=true npm --prefix lively.freezer run build-landing-page

loading-screen:
rm -rf lively.server/.module_cache
rm -rf lively.freezer/loading-screen
env CI=true npm --prefix lively.freezer run build-loading-screen

loading-screen-debug:
rm -rf lively.server/.module_cache
rm -rf lively.freezer/loading-screen
env CI=true DEBUG=true npm --prefix lively.freezer run build-loading-screen

clear-freezer-dir:
rm -rf lively.freezer/landing-page
rm -rf lively.freezer/loading-screen
Expand Down
2 changes: 1 addition & 1 deletion flatn/flatn-cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14618,7 +14618,7 @@ function sortByReference (depGraph, startNode) {
/**
* An interval defining an upper and a lower bound.
* @typedef { number[] } Interval
* @property {number} 0 - The lower bound of the interval.
* @property {number} 0 - The lower bound of the interval.
* @property {number} 1 - The upper bound of the interval.
*/

Expand Down
60 changes: 30 additions & 30 deletions lively.ast/lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,31 +495,23 @@ function imports (scope) {
return imports;
}

function exports (scope, resolve = false) {
if (resolve) resolveReferences(scope);

const exports = [];
for (const node of scope.exportDecls) {
var exportsStmt = statementOf(scope.node, node);
if (!exportsStmt) continue;

var from = exportsStmt.source ? exportsStmt.source.value : null;
function handleExportStmt (exportsStmt, scope, node = exportsStmt) {
var from = exportsStmt.source ? exportsStmt.source.value : null;

if (exportsStmt.type === 'ExportAllDeclaration') {
exports.push({
return [{
local: null,
exported: '*',
imported: '*',
fromModule: from,
node: node,
type: 'all'
});
continue;
}];
}

if (exportsStmt.type === 'ExportDefaultDeclaration') {
if (helpers.isDeclaration(exportsStmt.declaration)) {
exports.push({
return [{
local: exportsStmt.declaration.id ? exportsStmt.declaration.id.name : null,
exported: 'default',
type: exportsStmt.declaration.type === 'FunctionDeclaration'
Expand All @@ -531,39 +523,36 @@ function exports (scope, resolve = false) {
node: node,
decl: exportsStmt.declaration,
declId: exportsStmt.declaration.id
});
continue;
}];
}

if (exportsStmt.declaration.type === 'Identifier') {
const { decl, declId } = scope.resolvedRefMap.get(exportsStmt.declaration) || {};
exports.push({
return [{
local: exportsStmt.declaration.name,
exported: 'default',
fromModule: null,
node: node,
type: 'id',
decl,
declId
});
continue;
}]
}

// exportsStmt.declaration is an expression
exports.push({
return [{
local: null,
exported: 'default',
fromModule: null,
node: node,
type: 'expr',
decl: exportsStmt.declaration,
declId: exportsStmt.declaration
});
continue;
}];
}

if (exportsStmt.specifiers && exportsStmt.specifiers.length) {
exports.push(...exportsStmt.specifiers.map(exportSpec => {
return exportsStmt.specifiers.map(exportSpec => {
let decl, declId;
if (from) {
// "export { x as y } from 'foo'" is the only case where export
Expand All @@ -585,12 +574,11 @@ function exports (scope, resolve = false) {
decl,
declId
};
}));
continue;
})
}

if (exportsStmt.declaration && exportsStmt.declaration.declarations) {
exports.push(...exportsStmt.declaration.declarations.map(decl => {
return exportsStmt.declaration.declarations.map(decl => {
return {
local: decl.id ? decl.id.name : 'default',
exported: decl.id ? decl.id.name : 'default',
Expand All @@ -600,12 +588,11 @@ function exports (scope, resolve = false) {
decl: decl,
declId: decl.id
};
}));
continue;
})
}

if (exportsStmt.declaration) {
exports.push({
return [{
local: exportsStmt.declaration.id ? exportsStmt.declaration.id.name : 'default',
exported: exportsStmt.declaration.id ? exportsStmt.declaration.id.name : 'default',
type: exportsStmt.declaration.type === 'FunctionDeclaration'
Expand All @@ -617,9 +604,21 @@ function exports (scope, resolve = false) {
node: node,
decl: exportsStmt.declaration,
declId: exportsStmt.declaration.id
});
continue;
}]
}

return [];
}

function exports (scope, resolve = false) {
if (resolve) resolveReferences(scope);

const exports = [];
for (const node of scope.exportDecls) {
var exportsStmt = statementOf(scope.node, node);
if (!exportsStmt) continue;

exports.push(...handleExportStmt(exportsStmt, scope, node));
}

return arr.uniqBy(exports, (a, b) =>
Expand Down Expand Up @@ -665,5 +664,6 @@ export {
refWithDeclAt,
imports,
exports,
handleExportStmt,
queryNodes
};
7 changes: 6 additions & 1 deletion lively.classes/class-to-function-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,12 @@ function replaceClass (node, state, options) {
: classId
? [n.varDecl(classId, constructorTemplate(classId.name, fields, options)), n.varDecl(n.id(tempLivelyClassVar), classId)]
: [n.varDecl(n.id(tempLivelyClassVar), constructorTemplate(null, fields, options))],
n.ifStmt(n.funcCall(n.member(n.id('Object'), n.id('isFrozen')), [n.id(tempLivelyClassHolderVar)]), n.block([n.returnStmt(n.id(tempLivelyClassVar))]), null),
n.ifStmt(
n.logicalExpr('||',
n.funcCall(n.member(n.id('Object'), n.id('isFrozen')), [n.id(tempLivelyClassHolderVar)]),
n.funcCall(n.member(n.id('Object'), n.id('isFrozen')), [n.member(n.id(tempLivelyClassVar), n.id('prototype'))])),
n.block([n.returnStmt(n.id(tempLivelyClassVar))]),
null),
n.returnStmt(
n.funcCall(
options.functionNode,
Expand Down
4 changes: 2 additions & 2 deletions lively.classes/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as runtime from './runtime.js';
import { classToFunctionTransform } from './class-to-function-transform.js';
import { classToFunctionTransform, classToFunctionTransformBabel } from './class-to-function-transform.js';

export { runtime, classToFunctionTransform };
export { runtime, classToFunctionTransform, classToFunctionTransformBabel };
2 changes: 1 addition & 1 deletion lively.classes/tests/class-to-function-transform-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function classTemplate (className, superClassName, methodString, classMethodStri
return this[Symbol.for("lively-instance-initialize")].apply(this, arguments);
}
};${(useClassHolder || !className) ? '' : '\n var __lively_class__ = Foo;'}
if (Object.isFrozen(__lively_classholder__)) {
if (Object.isFrozen(__lively_classholder__) || Object.isFrozen(__lively_class__.prototype)) {
return __lively_class__;
}
return initializeClass(__lively_class__, superclass, ${methodString}, ${classMethodString}, ${ useClassHolder ? '__lively_classholder__' : 'null'}, ${moduleMeta}${pos});
Expand Down
57 changes: 56 additions & 1 deletion lively.freezer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"type": "module",
"dependencies": {
"@babel/core": "^7.12.3",
"@babel/core": "7.26.0",
"@babel/cli": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
Expand Down Expand Up @@ -49,6 +49,61 @@
"zlib": {
"~node": "@empty"
}
},
"importMap": {
"imports": {
"@babel/core": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/dev.index.js",
"@babel/types": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js"
},
"scopes": {
"esm://ga.jspm.io/": {
"#lib/config/files/index.js": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/config/files/index-browser.js",
"#lib/config/resolve-targets.js": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/config/resolve-targets-browser.js",
"#lib/transform-file.js": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/transform-file-browser.js",
"#node.js": "esm://ga.jspm.io/npm:[email protected]/browser.js",
"@ampproject/remapping": "esm://ga.jspm.io/npm:@ampproject/[email protected]/dist/remapping.umd.js",
"@babel/code-frame": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/compat-data/native-modules": "esm://ga.jspm.io/npm:@babel/[email protected]/native-modules.js",
"@babel/compat-data/plugins": "esm://ga.jspm.io/npm:@babel/[email protected]/plugins.js",
"@babel/generator": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-compilation-targets": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-module-imports": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-module-transforms": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-string-parser": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-validator-identifier": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helper-validator-option": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/helpers": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/parser": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/template": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@babel/traverse": "esm://ga.jspm.io/npm:@babel/[email protected]/lib/index.js",
"@jridgewell/gen-mapping": "esm://ga.jspm.io/npm:@jridgewell/[email protected]/dist/gen-mapping.umd.js",
"@jridgewell/resolve-uri": "esm://ga.jspm.io/npm:@jridgewell/[email protected]/dist/resolve-uri.umd.js",
"@jridgewell/set-array": "esm://ga.jspm.io/npm:@jridgewell/[email protected]/dist/set-array.umd.js",
"@jridgewell/sourcemap-codec": "esm://ga.jspm.io/npm:@jridgewell/[email protected]/dist/sourcemap-codec.umd.js",
"@jridgewell/trace-mapping": "esm://ga.jspm.io/npm:@jridgewell/[email protected]/dist/trace-mapping.umd.js",
"assert": "esm://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/assert.js",
"browserslist": "esm://ga.jspm.io/npm:[email protected]/index.js",
"buffer": "esm://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/buffer.js",
"caniuse-lite/dist/unpacker/agents": "esm://ga.jspm.io/npm:[email protected]/dist/unpacker/agents.js",
"convert-source-map": "esm://ga.jspm.io/npm:[email protected]/index.js",
"debug": "esm://ga.jspm.io/npm:[email protected]/src/browser.js",
"electron-to-chromium/versions": "esm://ga.jspm.io/npm:[email protected]/versions.js",
"fs": "esm://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/fs.js",
"gensync": "esm://ga.jspm.io/npm:[email protected]/index.js",
"globals": "esm://ga.jspm.io/npm:[email protected]/index.js",
"js-tokens": "esm://ga.jspm.io/npm:[email protected]/index.js",
"jsesc": "esm://ga.jspm.io/npm:[email protected]/jsesc.js",
"lru-cache": "esm://ga.jspm.io/npm:[email protected]/index.js",
"ms": "esm://ga.jspm.io/npm:[email protected]/index.js",
"node-releases/data/processed/envs.json": "esm://ga.jspm.io/npm:[email protected]/data/processed/envs.json.js",
"node-releases/data/release-schedule/release-schedule.json": "esm://ga.jspm.io/npm:[email protected]/data/release-schedule/release-schedule.json.js",
"path": "esm://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/path.js",
"picocolors": "esm://ga.jspm.io/npm:[email protected]/picocolors.browser.js",
"process": "esm://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/browser/process.js",
"semver": "esm://ga.jspm.io/npm:[email protected]/semver.js",
"yallist": "esm://ga.jspm.io/npm:[email protected]/yallist.js"
}
}
}
},
"lively": {
Expand Down
Loading