re-enable embroider-optimized#413
Conversation
| @@ -0,0 +1,38 @@ | |||
| import { helper } from '@ember/component/helper'; | |||
|
|
|||
| import config from 'ember-get-config'; | |||
There was a problem hiding this comment.
I think we can avoid using ember-get-config by making this a class-based helper and resolving the config ourselves.
|
👋 I was wondering if this would make sense to move this forward, i was thinking to convert this addon to v2 🤔 |
|
This addon doesn't provide that much value and has been removed from the v2 addon blueprint because of that. v2 addons that reach into the app for any reason are almost by definition a bad architecture when thinking about more modern package approaches 😞 Is there a usecase where a v2 addon version of this would make sense? I feel like this functionality would be better placed in a build plugin 🤔 |
|
I am mainly going of what we have currently and it's breaking on Vite build, a welcome alternatives (though I have not looked for alternatives myself yet) |
|
Are you making active use of this library? If not, i wouldn't look for a replacement. However! I do find stuff like: Useful |
|
I can confirm that unplugin-info does work in embroider+vite project: // package.json
{
"devDependnencies": {
"unplugin-info": "^1.2.4"
}
}// vite.config.mjs
import Info from 'unplugin-info/vite';
export default defineConfig({
plugins: [
Info(),
]
});// app/templates/application.gts
import Component from '@glimmer/component';
import { sha } from '~build/git';
export default class Application extends Component<MyRouteSignature> {
constructor(owner, args) {
super(owner, args);
console.log(`App Version: ${sha}`); // Just for demo purposes, don't do this at home kids!
}
<template>
{{outlet}}
</template>
} |
|
// ember-cli-build.js
const { Webpack } = require('@embroider/webpack');
return require('@embroider/compat').compatBuild(app, Webpack, {
// other options
packagerOptions: {
webpackConfig: {
plugins: [
require('unplugin-info/webpack')()
]
}
}
});I also tried it in a classic app by configuring ember-auto-import like this: const app = new EmberApp(defaults, {
autoImport: {
webpack: {
plugins: [
require('unplugin-info/webpack')()
]
},
},
});But it doesn't work, which seems to be the same problem as embroider-build/ember-auto-import#617 It's a shame, otherwise we could have deprecated this addon and added a migration guide for the unplugin-info equivalent. I guess we could still point people in the right direction without a deprecation though? Edit: In our app we simply display the version number as listed in the package.json file (without any git info) so we're just passing that from the environment.js file for now, which should work in classic apps as well. No extra deps required: // config/environment.js
const ENV = {
// ...
appVersion: require('../package.json').version,
// ...
};
|
No description provided.