-
Notifications
You must be signed in to change notification settings - Fork 142
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
What is the resolution for these types of errors: <addon> is trying to import <peerDep> from within its app tree. This is unsafe, because <addon> can't control which dependencies are resolvable from the app #1062
Comments
after trying that, it seems that I get multiple copies of xstate in my tree... which, when working with the componentManager api, ends up making everything broken with errors like this:
|
Move the implementation into your addon instead, and in the app tree have only a reexport of the code from the addon. This is the same thing the classic blueprint does if you ask it to generate an initializer. |
I gave that a go here: NullVoxPopuli/ember-statechart-component#163 Consistency is nice tho. 🙃 Here is the rollup config I have so far: import { nodeResolve } from '@rollup/plugin-node-resolve';
import { babel } from '@rollup/plugin-babel';
import { Addon } from '@embroider/addon-dev/rollup';
const addon = new Addon({
srcDir: 'src',
destDir: 'dist',
});
const extensions = ['.js', '.ts'];
const transpilation = [
nodeResolve({ resolveOnly: ['./'], extensions }),
babel({ babelHelpers: 'bundled', extensions }),
addon.dependencies(),
addon.hbs(),
];
export default [
{
input: 'src/index.ts',
output: { ...addon.output(), entryFileNames: '[name].js' },
plugins: [
...transpilation,
]
},
{
input: 'src/registration.ts',
output: { ...addon.output(), entryFileNames: 'instance-initializers/setup-ember-statechart-component.js' },
plugins: [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints(['instance-initializers/*.js']),
// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
// not everything in publicEntrypoints necessarily needs to go here.
addon.appReexports(['instance-initializers/setup-ember-statechart-component.js']),
...transpilation,
]
}
]; |
(Aside: that custom component manager for xstate is slick!) Maybe the duplication is because of your extra |
Thanks! I really enjoy that I can do this
createMachine and then... just render the return value |
Oh, I also only just noticed that you've got two separate rollup configs. That is going to duplicate any dependencies that are used by both. Instead I think you want one config with multiple inputs. It sounds like I need to test and adjust the default rollup config under typescript so you can stop being confused by it. It's supposed to handle all the inputs and outputs for you as long as you declare your publicEntrypoints. |
yeah, I switched to two separate rollup configs because I couldn't figure out how to do an instance-initializer for the app-js re-exports without re-working my addon's files to match the old file/folder structure.
This'd be much appreciated. Thar be dragons! |
Note: this is within a v2 addon / normal npm package.
I've reported / asked about this error before in Discord, and I don't remember what came of it, so I'm going to try some things and log my progress here in this issue.
Generically (for me to copy-paste to the title):
Specifically, for me:
I know initializers are nefarious, and here is how I'm abusing them:
I know that the initializer is part of the app tree, and it imports
xstate
, as does./-private/statechart-manager
, so there is no getting around that.I'm going to try to eliminate the addon's app tree entirely by moving the contents of my initializer to a
setup
method in the addon tree.The text was updated successfully, but these errors were encountered: