Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#73 use esm #114

Merged
merged 25 commits into from
Jul 10, 2024
Merged

Feature/#73 use esm #114

merged 25 commits into from
Jul 10, 2024

Conversation

lukas-schardt
Copy link
Collaborator

No description provided.

@@ -1,2 +1,2 @@
import { unsafeHTML } from '@popeindustries/lit-html-server/directives/unsafe-html';
import { unsafeHTML } from '@popeindustries/lit-html-server/directives/unsafe-html.mjs';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return id.startsWith('.')
? import(path.resolve(process.cwd(), id))
: import(path.resolve(process.cwd(), `./node_modules/${id}`));
console.log({ url: require.resolve(id) });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt Is this log supposed to stay in here?

@@ -3,8 +3,7 @@ import { getSerializableConfig, getSettings, getManifest } from '../config.js';
import posthtml from 'posthtml';
import posthtmlInsertAt from 'posthtml-insert-at';

import { InlineInject } from '../../decorators/service.js';
import ComponentLoader from '../loaders/component-loader.js';
import ComponentLoader from '../loaders/component-loader.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt This is probably not a problem but there is some whitespace in front of the statement.

.eslintrc Outdated
"rules": {
"prettier/prettier": "error"
},
"parserOptions": {
"ecmaVersion": 2021,
"ecmaVersion": 13,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt Can we use 2022 instead of 13? Who knows what 13 means

class LunaCache {
async clear() {
try {
Object.keys(require.cache).forEach((key) => delete require.cache[require.resolve(key)]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt I found some "left over" require statements

});
};
manifest.hooks.forEach(({ file }) => {
const module = require(path.resolve(path.join(basePath, file)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt I found some "left over" require statements

import ElementFactoryFactory from '../shared/element-factory';
import TemplateRenderer from "./template-renderer";
import ElementFactoryFactory from '../shared/element-factory.js';
import TemplateRenderer from "./template-renderer.js";

const ElementFactory = ElementFactoryFactory(TemplateRenderer);

const stubs = async () => [{
sources: ['@webtides/element-js'],
stub: require.resolve('./stubs/index.js'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt I found some "left over" require statements


const ElementFactory = ElementFactoryFactory(TemplateRenderer);

const stubs = async () => [{
sources: ['@webtides/element-js'],
stub: require.resolve('./stubs/index.js'),
}, {
sources: ['lit-html/directives/unsafe-html'],
sources: ['lit-html/directives/unsafe-html.js', 'lit-html/directives/unsafe-html'],
stub: require.resolve('./stubs/unsafe-html.js'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt I found some "left over" require statements


const ElementFactory = ElementFactoryFactory(TemplateRenderer);

const stubs = async () => [{
sources: ['@webtides/element-js/src/renderer/vanilla'],
sources: ['@webtides/element-js/src/renderer/vanilla', '@webtides/element-js/src/renderer/vanilla.js'],
stub: require.resolve('./stubs/index.js'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt I found some "left over" require statements

import TemplateRenderer from "./template-renderer";
import ElementFactory from './element-factory.js';
import TemplateRenderer from "./template-renderer.js";

const stubs = async () => [{
sources: ['lit'],
stub: require.resolve('./stubs/index.js'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt I found some "left over" require statements

@eddyloewen
Copy link
Contributor

I'm trying to use the new version in some of my recent projects. I'm still running into some errors...

This one for example:

"The component with the tag name "undefined" has no ElementFactory"

Also I had some trouble defining the factory. Would it be possible to set the factory by reference rather than just a string?

@eddyloewen
Copy link
Contributor

I also tried to use this new version for the ocean-crm demo project. I'm running into some weird bugs. I'm not getting any error messages. The luna startup just stops before registering components and prints out a bunch of bundled code for one single imported file (but not all of it...)
See: https://github.com/webtides/ocean-crm/tree/feature/type-module

@eddyloewen
Copy link
Contributor

I'm trying to use the new version in some of my recent projects. I'm still running into some errors...

This one for example:

"The component with the tag name "undefined" has no ElementFactory"

Also I had some trouble defining the factory. Would it be possible to set the factory by reference rather than just a string?

If I add some more logging:

The component with the tag name "undefined" has no ElementFactory {
component: { element: [class index], ElementFactory: undefined },
attributes: {}
}

I think this is the index page?

Also the luna-renderer package is still "commonjs" and bundles a bunch of require stuff - is that supposed to be like that?

@eddyloewen eddyloewen requested a review from quarkus July 5, 2024 12:37
@eddyloewen
Copy link
Contributor

@lukas-schardt @quarkus I think this should be good now! Please have a look 😆
I will update the changelog and write a small upgrade guide next week

@eddyloewen eddyloewen changed the base branch from develop to main July 5, 2024 12:40
@eddyloewen eddyloewen changed the title Draft: Feature/#73 use esm Feature/#73 use esm Jul 5, 2024
@eddyloewen eddyloewen merged commit e25d281 into main Jul 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants