-
Notifications
You must be signed in to change notification settings - Fork 187
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
Implement custom entry #325
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: a3ca889 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel like we should show the API in the changeset, and be a bit more clear about its usage.
@@ -62,6 +62,7 @@ module.exports = { | |||
|
|||
// Optional: | |||
title: 'My Awesome Library', | |||
entry: './src/entry', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entry: './src/entry', | |
entry: './src/entry.js', |
```js | ||
import '../path/to/your/theming-system/reset'; | ||
import '../path/to/your/theming-system/global-styles.css'; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```js | |
import '../path/to/your/theming-system/reset'; | |
import '../path/to/your/theming-system/global-styles.css'; | |
``` | |
```js | |
// playroom.config.js | |
entry: './src/entry.js', | |
``` | |
```js | |
// ./src/entry.js | |
import '../path/to/your/theming-system/reset'; | |
import '../path/to/your/theming-system/global-styles.css'; | |
``` |
```js | ||
import '../path/to/your/theming-system/reset'; | ||
import '../path/to/your/theming-system/global-styles.css'; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```js | |
import '../path/to/your/theming-system/reset'; | |
import '../path/to/your/theming-system/global-styles.css'; | |
``` | |
```js | |
// playroom.config.js | |
entry: './src/entry.js', | |
``` | |
```js | |
// ./src/entry.js | |
import '../path/to/your/theming-system/reset'; | |
import '../path/to/your/theming-system/global-styles.css'; | |
``` |
It became clear in seek-oss/braid-design-system#1448 that Playroom needed...
After scanning the module graph, here are the relavant code paths:
entry src/index.js
entry src/frame.js
entry src/preview.js
My first idea was to import a module at the top of each of the webpack-defined
__PLAYROOM_ALIAS__*__
aliases. That's because we might not know which one loads first, if we were to convert the code to ESM/TypeScript (which might happen in #313). So I wasn't convinced if it was a good idea.This implementation loads the entry at the top of each webpack entry:
playroom/lib/makeWebpackConfig.js
Lines 42 to 46 in 3aa9edd
This ensures the entry is imported only once per bundle, which is what we want. It also avoids the dual ESM/CJS package hazard, because the entry is loaded by webpack, not by our own code which can be
import
orrequire
calls.