Skip to content

Commit

Permalink
fix: fix esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed Dec 1, 2023
1 parent 7e4a59e commit 69d3a01
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 119 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"babel-loader": "^9.1.3",
"babel-plugin-named-asset-import": "0.3.8",
"canvas": "2.11.2",
"css-loader": "^6.8.1",
"css-mediaquery": "0.1.2",
"cssb-loader": "^6.8.1",
"cypress": "13.6.0",
"cypress-enter-plugin": "1.0.1",
"cypress-plugin-tab": "1.0.5",
Expand Down Expand Up @@ -120,7 +120,7 @@
"xmlserializer": "^0.6.1"
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"analyze": "GENERATE_SOURCEMAP=true react-app-rewired build && source-map-explorer 'build/bundle.js'",
"build": "GENERATE_SOURCEMAP=false react-app-rewired build && bash ./scripts/build-es.sh && node scripts/prepare-package.js",
"coverage": "yarn test --watchAll=false --coverage --coverageDirectory=coverage",
"cp": "generact --root src",
Expand Down
12 changes: 0 additions & 12 deletions packages/es/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,5 @@
["@babel/preset-env", { "modules": false }],
"@babel/preset-react"
],
"plugins": [
[
"babel-plugin-named-asset-import",
{
"loaderMap": {
"svg": {
"ReactComponent": "@svgr/webpack?-svgo![path]"
}
}
}
]
],
"ignore": ["**/*.test.js"]
}
60 changes: 30 additions & 30 deletions packages/wc/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@
* Running 'create-react-web-component --update' will replace this file.
*/

const EventHooksPlugin = require('event-hooks-webpack-plugin');
const { PromiseTask } = require('event-hooks-webpack-plugin/lib/tasks');
const rimraf = require('rimraf');
const fs = require('fs');

module.exports = function override(config, env) {
const overridenConfig = {
...config,
module: overrideModule(config.module),
output: overrideOutput(config.output),
optimization: overrideOptimization(config.optimization, env),
plugins: overridePlugins(config.plugins, env),
};

return overridenConfig;
};
// const EventHooksPlugin = require("event-hooks-webpack-plugin");
// const { PromiseTask } = require("event-hooks-webpack-plugin/lib/tasks");
// const rimraf = require("rimraf");
const fs = require("fs");

const overrideModule = (module) => {
// We override css and scss rules to generate a string css instead of an object.
Expand All @@ -30,23 +18,23 @@ const overrideModule = (module) => {

// We remove the auto svg loader to react component
const svgRuleIndex = module.rules[ruleIndex].oneOf.findIndex((rule) =>
'.svg'.match(rule.test),
".svg".match(rule.test),
);
module.rules[ruleIndex].oneOf[svgRuleIndex].test = /^((?!url).)*\.svg$/;

const cssRuleIndex = module.rules[ruleIndex].oneOf.findIndex((rule) =>
'.css'.match(rule.test),
".css".match(rule.test),
);
const scssRuleIndex = module.rules[ruleIndex].oneOf.findIndex((rule) =>
'.scss'.match(rule.test),
".scss".match(rule.test),
);

if (cssRuleIndex !== -1) {
module.rules[ruleIndex].oneOf[cssRuleIndex].use[0] = {
loader: 'to-string-loader',
loader: "to-string-loader",
};
module.rules[ruleIndex].oneOf[cssRuleIndex].use[1] = {
loader: 'css-loader',
loader: "css-loader",
options: {
// Needed until a new version of to-string-loader.
// See https://github.com/gajus/to-string-loader/pull/20 and https://github.com/gajus/to-string-loader/issues/21
Expand All @@ -56,10 +44,10 @@ const overrideModule = (module) => {
}
if (scssRuleIndex !== -1) {
module.rules[ruleIndex].oneOf[scssRuleIndex].use[0] = {
loader: 'to-string-loader',
loader: "to-string-loader",
};
module.rules[ruleIndex].oneOf[scssRuleIndex].use[1] = {
loader: 'css-loader',
loader: "css-loader",
options: {
// Needed until a new version of to-string-loader
// See https://github.com/gajus/to-string-loader/pull/20 and https://github.com/gajus/to-string-loader/issues/21
Expand All @@ -70,7 +58,7 @@ const overrideModule = (module) => {

module.rules[ruleIndex].oneOf.push({
test: /\.url\.svg$/,
loader: 'url-loader',
loader: "url-loader",
});

return module;
Expand All @@ -81,7 +69,7 @@ const overrideOutput = (output) => {

return {
...newOutput,
filename: 'bundle.js',
filename: "bundle.js",
};
};

Expand All @@ -99,7 +87,7 @@ const overrideOptimization = (optimization, env) => {
};

const overridePlugins = (plugins, env) => {
plugins[0].userOptions.inject = 'head';
plugins[0].userOptions.inject = "head";

/* plugins.push(
new EventHooksPlugin({
Expand All @@ -111,17 +99,29 @@ const overridePlugins = (plugins, env) => {
};

const copyBundleScript = async (env) => {
if (env !== 'production') {
if (env !== "production") {
return;
}

if (!fs.existsSync('build')) {
if (!fs.existsSync("build")) {
return;
}

fs.readdirSync('build').forEach((file) => {
if (file !== 'bundle.js') {
fs.readdirSync("build").forEach((file) => {
if (file !== "bundle.js") {
// rimraf.sync(`build/${file}`);
}
});
};

module.exports = function override(config, env) {
const overridenConfig = {
...config,
module: overrideModule(config.module),
output: overrideOutput(config.output),
optimization: overrideOptimization(config.optimization, env),
plugins: overridePlugins(config.plugins, env),
};

return overridenConfig;
};
79 changes: 4 additions & 75 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.23.3.tgz#3febd552541e62b5e883a25eb3effd7c7379db11"
integrity sha512-BmR4bWbDIoFJmJ9z2cZ8Gmm2MXgEDgjdWgpKmKWUt54UGFJdlj31ECtbaDvCG/qVdG3AQ1SfpZEs01lUFbzLOQ==

"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.16.0", "@babel/core@^7.4.5", "@babel/core@^7.7.5":
"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.16.0", "@babel/core@^7.7.5":
version "7.21.0"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.21.0.tgz#1341aefdcc14ccc7553fcc688dd8986a2daffc13"
integrity sha512-PuxUbxcW6ZYe656yL3EAhpy7qXKq0DmYsrJLpbB8XrsCP9Nm+XCg9XFMb5vIDliPD7+U/+M+QJlH17XOcB7eXA==
Expand Down Expand Up @@ -860,7 +860,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"

"@babel/plugin-syntax-jsx@^7.2.0", "@babel/plugin-syntax-jsx@^7.23.3":
"@babel/plugin-syntax-jsx@^7.23.3":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz#8f2e4f8a9b5f9aa16067e142c1ac9cd9f810f473"
integrity sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg==
Expand Down Expand Up @@ -1890,7 +1890,7 @@
"@babel/types" "^7.4.4"
esutils "^2.0.2"

"@babel/preset-react@^7.0.0", "@babel/preset-react@^7.12.5", "@babel/preset-react@^7.16.0":
"@babel/preset-react@^7.12.5", "@babel/preset-react@^7.16.0":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.18.6.tgz#979f76d6277048dc19094c217b507f3ad517dd2d"
integrity sha512-zXr6atUmyYdiWRVLOZahakYmOBHtWc2WGCkP8PYTgZi0iJXDY2CN180TdrIW4OGOAdLc7TifzDIvtx6izaRIzg==
Expand Down Expand Up @@ -4798,16 +4798,6 @@ ajv-keywords@^5.1.0:
dependencies:
fast-deep-equal "^3.1.3"

ajv@^5.0.0:
version "5.5.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
integrity sha512-Ajr4IcMXq/2QmMkEmSvxqfLN5zGmJ92gHXAeOXq1OekoH2rfDNsgdDoL2f7QaRCy7G/E6TpxBVdRuNraMztGHw==
dependencies:
co "^4.6.0"
fast-deep-equal "^1.0.0"
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0"

ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
Expand Down Expand Up @@ -5441,11 +5431,6 @@ babel-plugin-polyfill-regenerator@^0.5.3:
dependencies:
"@babel/helper-define-polyfill-provider" "^0.4.3"

babel-plugin-react-svg@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/babel-plugin-react-svg/-/babel-plugin-react-svg-3.0.3.tgz#7da46a0bd8319f49ac85523d259f145ce5d78321"
integrity sha512-Pst1RWjUIiV0Ykv1ODSeceCBsFOP2Y4dusjq7/XkjuzJdvS9CjpkPMUIoO4MLlvp5PiLCeMlsOC7faEUA0gm3Q==

babel-plugin-transform-react-remove-prop-types@^0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz#f2edaf9b4c6a5fbe5c1d678bfb531078c1555f3a"
Expand Down Expand Up @@ -8518,11 +8503,6 @@ etag@~1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==

event-hooks-webpack-plugin@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/event-hooks-webpack-plugin/-/event-hooks-webpack-plugin-2.3.0.tgz#cc351cc72c762ce646e8dd9c937b83d221ef5fd7"
integrity sha512-Q6PimZjcAloZyRCykylNMNG0p9t2hhgY874aFEff5886lVA2mwB4OALB15Nh8O6wAeqt2S685xoNZJCG4tZRPg==

event-stream@=3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571"
Expand Down Expand Up @@ -8730,11 +8710,6 @@ extsprintf@^1.2.0:
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.1.tgz#8d172c064867f235c0c84a596806d279bf4bcc07"
integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA==

fast-deep-equal@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"
integrity sha512-fueX787WZKCV0Is4/T2cyAdM4+x1S3MXXOAhavE1ys/W42SHAPacLTQhucja22QBYrfGw50M2sRiXPtTGv9Ymw==

fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
Expand Down Expand Up @@ -11464,11 +11439,6 @@ json-parse-even-better-errors@^2.3.0, json-parse-even-better-errors@^2.3.1:
resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d"
integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==

json-schema-traverse@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340"
integrity sha512-4JD/Ivzg7PoW8NzdrBSr3UFwC9mHgvI7Z6z3QGBsSHgKaRTUDmyZAAKJo2UbG1kUVfS9WS8bi36N49U1xw43DA==

json-schema-traverse@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
Expand Down Expand Up @@ -11880,7 +11850,7 @@ loader-runner@^4.2.0:
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1"
integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==

loader-utils@^1.0.0, loader-utils@^1.0.2, loader-utils@^1.2.3:
loader-utils@^1.0.0:
version "1.4.2"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.2.tgz#29a957f3a63973883eb684f10ffd3d151fec01a3"
integrity sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==
Expand Down Expand Up @@ -11955,11 +11925,6 @@ lodash.camelcase@^4.3.0:
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==

lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==

[email protected], lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
Expand Down Expand Up @@ -14804,27 +14769,6 @@ [email protected]:
webpack-dev-server "^4.9.2"
webpack-merge "^4.2.2"

react-svg-core@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/react-svg-core/-/react-svg-core-3.0.3.tgz#5d856efeaa4d089b0afeebe885b20b8c9500d162"
integrity sha512-Ws3eM3xCAwcaYeqm4Ajcz3zxBYNI6BeTWWhFR0cpOT+pWuVtozgHYK9xUM0S/ilapZgYMQDe49XgOxpvooFq4w==
dependencies:
"@babel/core" "^7.4.5"
"@babel/plugin-syntax-jsx" "^7.2.0"
"@babel/preset-react" "^7.0.0"
babel-plugin-react-svg "^3.0.3"
lodash.clonedeep "^4.5.0"
lodash.isplainobject "^4.0.6"
svgo "^1.2.2"

react-svg-loader@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/react-svg-loader/-/react-svg-loader-3.0.3.tgz#8baa2d5daa32523dfd0745425ac65e0a90edae15"
integrity sha512-V1KnIUtvWVvc4xCig34n+f+/74ylMMugB2FbuAF/yq+QRi+WLi2hUYp9Ze3VylhA1D7ZgRygBh3Ojj8S3TPhJA==
dependencies:
loader-utils "^1.2.3"
react-svg-core "^3.0.3"

react-themeable@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/react-themeable/-/react-themeable-1.1.0.tgz#7d4466dd9b2b5fa75058727825e9f152ba379a0e"
Expand All @@ -14842,14 +14786,6 @@ react-transition-group@^4.3.0, react-transition-group@^4.4.0, react-transition-g
loose-envify "^1.4.0"
prop-types "^15.6.2"

[email protected]:
version "0.1.4-alpha"
resolved "https://registry.yarnpkg.com/react-web-component-style-loader/-/react-web-component-style-loader-0.1.4-alpha.tgz#3405736481b11fe9e1cc65fd21acd507ce7b296b"
integrity sha512-aW3GnhdpFZgMBgJnDqk3oebMv7Qa5W+KBGKy/CxceYuLrvSsoiReenH2q0AomtEbjLdSgC4QsoTLUEleDwx2FA==
dependencies:
loader-utils "^1.0.2"
schema-utils "^0.3.0"

[email protected]:
version "2.0.2"
resolved "https://registry.yarnpkg.com/react-web-component/-/react-web-component-2.0.2.tgz#ee2f023f7dfd463fad85431f72959655fc7cd141"
Expand Down Expand Up @@ -15639,13 +15575,6 @@ [email protected]:
ajv "^6.12.2"
ajv-keywords "^3.4.1"

schema-utils@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.3.0.tgz#f5877222ce3e931edae039f17eb3716e7137f8cf"
integrity sha512-QaVYBaD9U8scJw2EBWnCBY+LJ0AD+/2edTaigDs0XLDLBfJmSUK9KGqktg1rb32U3z4j/XwvFwHHH1YfbYFd7Q==
dependencies:
ajv "^5.0.0"

schema-utils@^2.6.5:
version "2.7.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
Expand Down

2 comments on commit 69d3a01

@vercel
Copy link

@vercel vercel bot commented on 69d3a01 Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 69d3a01 Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.