-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: make tokens package native ESM (build transforms)
#30620
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
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9769bf4
Test swc transform imports
spmonahan c43dd19
get swc transform working on tokens
spmonahan b2201da
chore: patch just-task to support esm and update swc transform plugin
Hotell 32e2193
chore(tokens): make jest and just work in native ESM
Hotell ba3a965
chore(tools): apply single version policy for dev deps
Hotell 9717e62
feat(tokens): make module ESM native
Hotell 301496b
feat(.storybook): enable native ESM package resolution
Hotell fa54c27
chore(vr-tests-*): enable native ESM package resolution
Hotell 09aa074
chore(perf-test-react-components): enable native ESM package resolution
Hotell 842833c
chore: bump webpack n friends
Hotell bdafc6b
chore: add esm integration test
Hotell 7508343
changefiles
Hotell 7ded1d8
chore: fix types after webpack bump
Hotell 4d6524e
chore: fix types after webpack bump
Hotell 5a00c38
feat(tokens): demonstrate actuall .mjs build transforms only without …
Hotell 75085fc
chore: add babel cli to demo griffel babel transform issue outside ju…
Hotell a0108e9
chore(esm-integration-app): add griffel
Hotell e4e6204
chore: bump swc deindent plugin to support swc 1.4
Hotell d8d7fa1
chore: resolve yarn.lock after rebase
Hotell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "@fluentui/esm-integration-test", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "bundle": "webpack", | ||
| "start": "webpack-dev-server" | ||
| }, | ||
| "devDependencies": { | ||
| "@fluentui/react-theme": "*" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "@fluentui/esm-integration-test", | ||
| "$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
| "projectType": "application", | ||
| "implicitDependencies": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { tokens, webLightTheme } from '@fluentui/react-theme'; | ||
| import { makeStyles, shorthands } from '@griffel/react'; | ||
|
|
||
| const vars = Object.entries(tokens) | ||
| .map(([key, value]) => { | ||
| return `${value.replace('var(', '').replace(')', '')}: ${webLightTheme[key as keyof typeof webLightTheme]};`; | ||
| }) | ||
| .join('\n'); | ||
|
|
||
| const style = makeStyles({ | ||
| root: { | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| width: '80%', | ||
| height: '80%', | ||
| overflowY: 'scroll', | ||
| ...shorthands.margin('auto'), | ||
| }, | ||
| item: { | ||
| ...shorthands.padding('10px'), | ||
| }, | ||
| }); | ||
|
|
||
| export const App = () => { | ||
| const classes = style(); | ||
| return ( | ||
| <main> | ||
| <style>{`:root { | ||
| ${vars} | ||
| }`}</style> | ||
| <h1>Hello</h1> | ||
| <section className={classes.root}> | ||
| {Object.entries(tokens).map(([key, value]) => { | ||
| return ( | ||
| <div className={classes.item} style={{ backgroundColor: value }}> | ||
| {key} | ||
| </div> | ||
| ); | ||
| })} | ||
| </section> | ||
| </main> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { render } from 'react-dom'; | ||
| import { createElement } from 'react'; | ||
| import { App } from './app'; | ||
|
|
||
| main(); | ||
|
|
||
| function main() { | ||
| const root = document.getElementById('root'); | ||
|
|
||
| render(createElement(App), root); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "moduleResolution": "Node", | ||
| "pretty": true, | ||
| "module": "ESNext", | ||
| "target": "ES2020", | ||
| "noEmit": true, | ||
| "lib": ["ES2020", "dom"], | ||
| "outDir": "dist", | ||
| "isolatedModules": true, | ||
| "skipLibCheck": true, | ||
| "jsx": "react-jsx", | ||
| "strict": true | ||
| }, | ||
| "include": ["src"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // @ts-check | ||
|
|
||
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
|
|
||
| /** | ||
| * | ||
| * @type {import("webpack").RuleSetRule} | ||
| */ | ||
| const griffelRule = { | ||
| test: /\.tsx?$/, | ||
| exclude: [/node_modules/], | ||
| enforce: 'post', | ||
| use: [ | ||
| { | ||
| loader: '@griffel/webpack-loader', | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| /** | ||
| * | ||
| * @type {import("webpack").RuleSetRule} | ||
| */ | ||
| const swcRule = { | ||
| test: /\.tsx?$/, | ||
| exclude: /node_modules/, | ||
| use: { | ||
| loader: 'swc-loader', | ||
| options: { | ||
| jsc: { | ||
| target: 'es2019', | ||
| parser: { | ||
| syntax: 'typescript', | ||
| tsx: true, | ||
| decorators: true, | ||
| dynamicImport: true, | ||
| }, | ||
| transform: { | ||
| decoratorMetadata: true, | ||
| legacyDecorator: true, | ||
| react: { | ||
| runtime: 'automatic', | ||
| }, | ||
| }, | ||
| keepClassNames: true, | ||
| externalHelpers: true, | ||
| loose: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| module.exports = /** @type {import('webpack').Configuration} */ ({ | ||
| mode: 'development', | ||
| entry: './src/main.ts', | ||
| output: { | ||
| filename: 'bundle.js', | ||
| path: __dirname + '/dist', | ||
| }, | ||
| resolve: { | ||
| extensions: ['.tsx', '.ts', '.js'], | ||
| }, | ||
| module: { | ||
| rules: [griffelRule, swcRule], | ||
| }, | ||
| plugins: [ | ||
| new HtmlWebpackPlugin({ | ||
| templateContent: '<div id="root"></div>', | ||
| }), | ||
| ], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-dialog-70565202-f312-4e39-aa2c-b77b74347a77.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "chore: add esm integration test", | ||
| "packageName": "@fluentui/react-dialog", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "none" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-jsx-runtime-b2d7b92c-54f8-4e81-8efa-40a555466fb5.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "chore: add esm integration test", | ||
| "packageName": "@fluentui/react-jsx-runtime", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "none" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-tree-72dc0e26-ccfa-401b-abc5-dc7b6c38b0f2.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "chore: add esm integration test", | ||
| "packageName": "@fluentui/react-tree", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "none" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-utilities-ba34d141-88bc-41f4-9a18-9b8b61772282.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "none", | ||
| "comment": "chore: add esm integration test", | ||
| "packageName": "@fluentui/react-utilities", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "none" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-tokens-7507bf1e-16de-4efa-87d1-c90f87e3ce4d.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "feat: make module native ESM", | ||
| "packageName": "@fluentui/tokens", | ||
| "email": "[email protected]", | ||
| "dependentChangeType": "patch" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
needed because SB6 uses webpack4
webpack/webpack#13252