diff options
author | Sebastian <sebasjm@gmail.com> | 2023-12-01 10:08:47 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-12-01 10:09:53 -0300 |
commit | ce2e58962cb0a61725fe0fe3dd8535965f482b95 (patch) | |
tree | 17277f34e7d665e5fdcc4acd012de2209b5cefd9 /packages/taler-wallet-webextension | |
parent | 968ca3cb9a18196605f55ae3413dd601e0319829 (diff) | |
download | wallet-core-ce2e58962cb0a61725fe0fe3dd8535965f482b95.tar.xz |
linaria faster version
Diffstat (limited to 'packages/taler-wallet-webextension')
3 files changed, 7 insertions, 123 deletions
diff --git a/packages/taler-wallet-webextension/linaria-esbuild-plugin-fixed.mjs b/packages/taler-wallet-webextension/linaria-esbuild-plugin-fixed.mjs deleted file mode 100644 index 9f7576fc1..000000000 --- a/packages/taler-wallet-webextension/linaria-esbuild-plugin-fixed.mjs +++ /dev/null @@ -1,108 +0,0 @@ -// src/index.ts -import fs from "fs"; -import path from "path"; -import { transformSync } from "esbuild"; -import { slugify, transform } from "@linaria/babel-preset"; -var nodeModulesRegex = /^(?:.*[\\/])?node_modules(?:[\\/].*)?$/; -function linaria({ sourceMap, preprocessor, esbuildOptions, ...rest } = {}) { - let options = esbuildOptions; - return { - name: "linaria", - setup(build) { - const cssLookup = /* @__PURE__ */ new Map(); - const asyncResolve = async (token, importer) => { - const context = path.isAbsolute(importer) - ? path.dirname(importer) - : path.join(process.cwd(), path.dirname(importer)); - const result = await build.resolve(token, { - resolveDir: context, - kind: "import-statement", - }); - if (result.errors.length > 0) { - throw new Error(`Cannot resolve ${token}`); - } - return result.path; - }; - build.onResolve({ filter: /\.linaria\.css$/ }, (args) => { - return { - namespace: "linaria", - path: args.path, - }; - }); - build.onLoad({ filter: /.*/, namespace: "linaria" }, (args) => { - return { - contents: cssLookup.get(args.path), - loader: "css", - resolveDir: path.basename(args.path), - }; - }); - build.onLoad({ filter: /\.(js|jsx|ts|tsx)$/ }, async (args) => { - const rawCode = fs.readFileSync(args.path, "utf8"); - const { ext, name: filename } = path.parse(args.path); - const loader = ext.replace(/^\./, ""); - if (nodeModulesRegex.test(args.path)) { - return { - loader, - contents: rawCode, - }; - } - if (!options) { - options = {}; - if ("jsxFactory" in build.initialOptions) { - options.jsxFactory = build.initialOptions.jsxFactory; - } - if ("jsxFragment" in build.initialOptions) { - options.jsxFragment = build.initialOptions.jsxFragment; - } - } - const transformed = transformSync(rawCode, { - ...options, - sourcefile: args.path, - sourcemap: sourceMap, - loader, - }); - let { code } = transformed; - if (sourceMap) { - const esbuildMap = Buffer.from(transformed.map).toString("base64"); - code += `/*# sourceMappingURL=data:application/json;base64,${esbuildMap}*/`; - } - const result = await transform( - code, - { - filename: args.path, - preprocessor, - pluginOptions: rest, - }, - asyncResolve - ); - if (!result.cssText) { - return { - contents: code, - loader, - resolveDir: path.dirname(args.path), - }; - } - let { cssText } = result; - const slug = slugify(cssText); - const cssFilename = `${filename}_${slug}.linaria.css`; - let contents = `import ${JSON.stringify(cssFilename)}; ${result.code}`; - if (sourceMap && result.cssSourceMapText) { - const map = Buffer.from(result.cssSourceMapText).toString("base64"); - cssText += `/*# sourceMappingURL=data:application/json;base64,${map}*/`; - const linariaMap = Buffer.from( - JSON.stringify(result.sourceMap) - ).toString("base64"); - contents += `/*# sourceMappingURL=data:application/json;base64,${linariaMap}*/`; - } - cssLookup.set(cssFilename, cssText); - return { - contents, - loader, - resolveDir: path.dirname(args.path), - }; - }); - }, - }; -} -export { linaria as default }; -//# sourceMappingURL=index.mjs.map diff --git a/packages/taler-wallet-webextension/package.json b/packages/taler-wallet-webextension/package.json index e790f6986..d610cc9d7 100644 --- a/packages/taler-wallet-webextension/package.json +++ b/packages/taler-wallet-webextension/package.json @@ -12,7 +12,7 @@ "clean": "rm -rf dist lib tsconfig.tsbuildinfo", "test": "./test.mjs && mocha --require source-map-support/register 'dist/test/**/*.test.js' 'dist/test/**/test.js'", "test:coverage": "nyc pnpm test", - "compile": "./patch-linaria.sh && tsc && ./build.mjs", + "compile": "tsc && ./build.mjs", "typedoc": "typedoc --out dist/typedoc ./src/ --entryPointStrategy expand", "dev": "./dev.mjs", "pretty": "prettier --write src", @@ -48,10 +48,11 @@ "@babel/preset-typescript": "7.18.6", "@gnu-taler/pogen": "workspace:*", "@gnu-taler/web-util": "workspace:*", - "@linaria/babel-preset": "^4.4.5", - "@linaria/core": "^4.2.10", - "@linaria/esbuild": "^4.2.11", - "@linaria/react": "^4.3.8", + "@linaria/babel-preset": "5.0.4", + "@linaria/core": "5.0.2", + "@linaria/esbuild": "5.0.4", + "@linaria/react": "5.0.3", + "@linaria/shaker": "5.0.3", "@types/chai": "^4.3.0", "@types/chrome": "0.0.197", "@types/history": "^4.7.8", @@ -75,4 +76,4 @@ "pogen": { "domain": "taler-wallet-webex" } -}
\ No newline at end of file +} diff --git a/packages/taler-wallet-webextension/patch-linaria.sh b/packages/taler-wallet-webextension/patch-linaria.sh deleted file mode 100755 index 46dc57927..000000000 --- a/packages/taler-wallet-webextension/patch-linaria.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# This file is in the public domain. - -# Fix: ERROR Cannot find module 'xxx' with esbuild 0.17 and linaria 4.2 -# remove when this PR is accepted -# https://github.com/callstack/linaria/pull/1256 - -cp linaria-esbuild-plugin-fixed.mjs ./node_modules/@linaria/esbuild/dist/index.mjs - |