![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Using Babel Macro Extract Metadatas from Codes
Example: https://github.com/fe-since2019/meta.macro/tree/master/example/router-usage
npm install --save-dev meta.macro
// File: /Users/me/workspaces/my-app/src/App.js
import Controller from 'meta.macro';
@Controller('/home', {async: true, chunk: 'main'})
class App extends React.Component {
render() {
return (
<div>Hello World</div>
);
}
}
Data Extract from Code
{
"/Users/me/workspaces/my-app/src/App.js": {
"callee": "Controller",
"params": [
"/home",
{
"async": true,
"chunk": "main"
}
]
}
}
Supportted Config Files: https://github.com/kentcdodds/babel-plugin-macros/blob/HEAD/other/docs/author.md#config-experimental
// babel-plugin-macros.config.js
module.exports = {
'meta.macro': function(metadata){
// TODO
// do something...
},
}
Before
my-app
├── package.json
├── babel-plugin-macros.config.js
├── .gitignore
└── src
├── App.js
├── Loading.js
└── pages
├── HomePage.js
└── LoginPage.js
// src/App.js
import './pages/HomePage.js'
import './pages/LoginPage.js'
ReactDOM.render(
<App />,
document.getElementById('root')
);
// babel-plugin-macros.config.js
const routerCodeGenerator = require('meta.macro/lib/router.code.js');
module.exports = {
'meta.macro': routerCodeGenerator
}
// src/pages/LoginPage.js
import React from 'react';
import Controller from 'meta.macro';
@Controller('/login')
class LoginPage extends React.Component {
render() {
return (
<div>Login</div>
);
}
}
// src/pages/HomePage
import React from 'react';
import Page from 'meta.macro';
@Page('/home', { async: true, chunk: 'main' })
class HomePage extends React.Component {
render() {
return (
<div>Home Page</div>
);
}
}
After
my-app
├── package.json
├── babel-plugin-macros.config.js
├── .gitignore
└── src
├── router.js
├── router-config.json
├── Loading.js
└── pages
├── HomePage.js
└── LoginPage.js
Generate File src/router.js
// ~ is Webpack Alias for <project>/src folder
import React from 'react';
import Loadable from 'react-loadable';
import Loading from './Loading';
import LoginPage from '~/pages/LoginPage';
const lazy = loader => Loadable({
delay: 400,
loading: Loading,
loader,
});
const rootConfig = [
{
path: "/home",
component: lazy(() => import(/* webpackChunkName: "main" */ '~/react/pages/HomePage.js')),
}, {
path: "/login",
component: LoginPage
}
];
export default rootConfig;
Generate File src/router-config.json
{
"/Users/me/workspaces/my-app/src/pages/LoginPage.js": {
"callee": "Controller",
"params": []
},
"/Users/me/workspaces/my-app/src/pages/HomePage.js": {
"callee": "Page",
"params": [
"/home",
{
"async": true,
"chunk": "main"
}
]
}
}
FAQs
Using Babel Macro Extract Metadatas from Codes
The npm package meta.macro receives a total of 1 weekly downloads. As such, meta.macro popularity was classified as not popular.
We found that meta.macro demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.