Skip to content

Commit

Permalink
update module mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Feb 22, 2023
1 parent 4c80df2 commit ca0e80d
Show file tree
Hide file tree
Showing 9 changed files with 5,316 additions and 5,441 deletions.
25 changes: 25 additions & 0 deletions packages/rollup-plugin/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jest/recommended",
],
globals: {
module: "readonly",
process: "readonly",
__dirname: "readonly",
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["react"],
rules: {},
};
25 changes: 0 additions & 25 deletions packages/rollup-plugin/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/rollup-plugin/.npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__tests__
.eslintrc.js
.eslintrc.cjs
*.tgz
1 change: 0 additions & 1 deletion packages/rollup-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@

[logo]: https://wq.io/images/@wq/rollup-plugin.svg
[docs]: https://wq.io/@wq/rollup-plugin

[wq.app]: https://wq.io/wq.app/
[wq]: https://wq.io/wq/
10,619 changes: 5,252 additions & 5,367 deletions packages/rollup-plugin/package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions packages/rollup-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@wq/rollup-plugin",
"version": "1.3.0",
"version": "2.0.0-alpha.0",
"description": "Build custom wq plugins that integrate with wq.js",
"type": "module",
"main": "src/index.js",
"scripts": {
"test": "jest",
"prettier": "prettier --write .",
"lint": " eslint src/"
"lint": "eslint ."
},
"repository": {
"type": "git",
Expand All @@ -29,17 +30,16 @@
"homepage": "https://wq.io/@wq/rollup-plugin",
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-transform-react-jsx": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@rollup/plugin-babel": "^5.2.1",
"eslint": "^7.11.0",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-react": "^7.21.5",
"jest": "^26.5.3",
"prettier": "^2.1.2",
"rollup": "^2.32.0",
"rollup-plugin-prettier": "^2.1.0"
"@babel/plugin-transform-react-jsx": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"@rollup/plugin-babel": "^6.0.3",
"eslint": "^8.34.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-react": "^7.32.2",
"jest": "^29.4.3",
"prettier": "^2.8.4",
"rollup": "^3.17.2",
"rollup-plugin-prettier": "^3.0.0"
},
"prettier": {
"filepath": "input.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { usePluginState } from "@wq/react";
import { List, ListItem } from "@wq/material";
import { Grid } from "@mui/material";

export default function Test() {
const state = usePluginState("myPlugin");
Expand All @@ -9,6 +10,9 @@ export default function Test() {
{state.values.map((value) => (
<ListItem key={value.id}>{value.label}</ListItem>
))}
<ListItem>
<Grid />
</ListItem>
</List>
);
}
12 changes: 8 additions & 4 deletions packages/rollup-plugin/src/__tests__/fixtures/plugin/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const { "@wq/react": react } = modules;

const { "@wq/material": material } = modules;

const { "@mui/material": muiMaterial } = modules;

function Test() {
const state = react.usePluginState("myPlugin");
return /*#__PURE__*/ React.createElement(
Expand All @@ -19,6 +21,11 @@ function Test() {
},
value.label
)
),
/*#__PURE__*/ React.createElement(
material.ListItem,
null,
/*#__PURE__*/ React.createElement(muiMaterial.Grid, null)
)
);
}
Expand All @@ -33,14 +40,12 @@ var input = {
};
},
},

reducer(state, action) {
switch (action.type) {
case "MYPLUGIN_SET_VALUES":
return {
values: action.payload,
};

default:
return (
state || {
Expand All @@ -49,10 +54,9 @@ var input = {
);
}
},

components: {
Test,
},
};

export default input;
export { input as default };
43 changes: 13 additions & 30 deletions packages/rollup-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const prefix = "\0wq-bundle:",
react: {
name: "React",
},
"react/jsx-runtime": {
name: "jsxRuntime",
},
"react-dom": {
name: "ReactDOM",
},
Expand All @@ -15,23 +18,17 @@ const prefix = "\0wq-bundle:",
formik: {
name: "formik",
},
"@material-ui/styles": {
name: "muiStyles",
},
"@material-ui/utils": {
name: "muiUtils",
},
"@material-ui/core/ButtonBase": {
name: "ButtonBase",
"@emotion/styled": {
name: "emStyled",
},
"@material-ui/core/Paper": {
name: "Paper",
"@emotion/react": {
name: "emReact",
},
"@material-ui/core/styles/withStyles": {
name: "withStyles",
"@mui/utils": {
name: "muiUtils",
},
"@material-ui/core/styles/colorManipulator": {
name: "colorManipulator",
"@mui/material": {
name: "muiMaterial",
},
"mapbox-gl": {
name: "MapboxGL",
Expand Down Expand Up @@ -65,32 +62,18 @@ const prefix = "\0wq-bundle:",
name: "mapgl",
hasDefault: true,
},
},
muiCoreImports = {};

Object.keys(modules)
.filter((id) => id.match("@material-ui/core"))
.forEach(
(id) => (muiCoreImports[id.replace("@material-ui/core", "..")] = id)
);
};

module.exports = function wq() {
return {
name: "@wq/rollup-plugin",
resolveId(id, importer) {
resolveId(id) {
if (id == "./wq.js") {
return { id, external: true };
}
if (id.match(/\?commonjs-proxy$/)) {
id = id.replace(/^\0/, "").replace(/\?commonjs-proxy$/, "");
}
if (
importer &&
importer.match(/@material-ui.core/) &&
muiCoreImports[id]
) {
id = muiCoreImports[id];
}
if (modules[id]) {
return {
id: `${prefix}${id}`,
Expand Down

0 comments on commit ca0e80d

Please sign in to comment.