Open seomaz opened 2 years ago
@samouri @sebastianbenz 🙏
@seomaz - do you have any interest in doing the migration?
@seomaz - do you have any interest in doing the migration?
yes, we need help
@seomaz - do you have any interest in doing the migration?
any update on this?
using wrangler 2 when i try to import { AmpOptimizer } from '@ampproject/toolbox-optimizer';
Uncaught ReferenceError: __dirname is not defined at index.js:7652:26 in node_modules/@ampproject/toolbox-optimizer/lib/cache.js at index.js:18:50 in __require2 at index.js:7669:17 in node_modules/@ampproject/toolbox-optimizer/lib/DomTransformer.js at index.js:18:50 in __require2 at index.js:7814:9 in node_modules/@ampproject/toolbox-optimizer/index.js at index.js:18:50 in __require2 at index.js:7830:40 [code: 10021]
@sebastianbenz please help
@seomaz - do you have any interest in doing the migration?
any update on this?
using wrangler 2 when i try to
import { AmpOptimizer } from '@ampproject/toolbox-optimizer';
Uncaught ReferenceError: __dirname is not defined at index.js:7652:26 in node_modules/@ampproject/toolbox-optimizer/lib/cache.js at index.js:18:50 in __require2 at index.js:7669:17 in node_modules/@ampproject/toolbox-optimizer/lib/DomTransformer.js at index.js:18:50 in __require2 at index.js:7814:9 in node_modules/@ampproject/toolbox-optimizer/index.js at index.js:18:50 in __require2 at index.js:7830:40 [code: 10021]
@sebastianbenz please help
Not sure if the placement is correct however the following code in cache.js resolves this issue.
const _dirname = path.resolve()
The next issue requiring a solution is shown in the following error from the code on line 248 of DomTransformer.js
Transformer = require(./transformers/${Transformer}.js
);
From what I can decipher the latest version of Nodejs no longer supports dynamic require.
service core:user:amp32-opt1: Uncaught Error: Dynamic require of "./transformers/OptimizeAmpBind" is not supported at core:user:amp32-opt1:11:11 at core:user:amp32-opt1:8169:29 at core:user:amp32-opt1:8167:56 in initTransformers_ at core:user:amp32-opt1:8164:16 in setConfig at core:user:amp32-opt1:8129:16 in DomTransformer at core:user:amp32-opt1:8205:47 in create at core:user:amp32-opt1:8533:25 in getOptimizer at core:user:amp32-opt1:8484:19 at core:user:amp32-opt1:8926:3
A possible solution would be to case each of the transformers with a specific require for each transformer
Cloudflare wrangler 1.0 to 2.0: https://developers.cloudflare.com/workers/wrangler/migration/eject-webpack/#i-use-type--webpack-and-webpack_config--pathtowebpackconfigjs-to-perform-code-transforms-andor-other-code-modifying-functionality