magento / pwa-studio

🛠Development tools to build, optimize and deploy Progressive Web Applications for Magento 2.
https://developer.adobe.com/commerce/pwa-studio/
Open Software License 3.0
1.07k stars 683 forks source link

[bug]: local-intercept doesnt work in docker container #4321

Open abalshakou opened 1 month ago

abalshakou commented 1 month ago

Describe the bug

My local-interept.js do nothing inside docker composer container. If i use same code on local build - it works as needed - on dev mode or on build

To reproduce

Steps to reproduce the behavior:

  1. Put my developer code to docker container with Dockerfile

`FROM node:18.17.0

ENV PATH /node_modules/.bin:$PATH

RUN apt-get update && apt-get install -y sudo openssl && apt-get clean

RUN usermod -u 1001 node RUN groupmod -g 1001 node

RUN groupadd -g 1000 customuser RUN useradd --no-log-init -d /home/customuser -s /bin/bash -u 1000 -g customuser customuser RUN echo "customuser:customuser" | chpasswd && adduser customuser sudo

RUN mkdir -p /home/customuser RUN chown -R customuser:customuser /home/customuser

ENV NODE_OPTIONS=--openssl-legacy-provider ENV NODE_TLS_REJECT_UNAUTHORIZED=0 ENV MAGENTO_BACKEND_URL=https://staging.x.com/ ENV PORT=443 ENV CHECKOUT_BRAINTREE_TOKEN=xxx

COPY . . RUN ls -la RUN export NODE_TLS_REJECT_UNAUTHORIZED=0 RUN export NODE_OPTIONS=--openssl-legacy-provider RUN export MAGENTO_BACKEND_URL=https://staging.x.com/ RUN export PORT=443 RUN export CHECKOUT_BRAINTREE_TOKEN=xxx RUN yarn

RUN yarn build USER customuser

CMD ["yarn", "start"]`

my local-intercept like this:

`const { Targetables } = require('@magento/pwa-buildpack');

function localIntercept(targets) { const targetables = Targetables.using(targets);

const productComponent = targetables.reactComponent(
    '@magento/venia-ui/lib/RootComponents/Product/product.js'
);

productComponent.insertBeforeSource(
    "import { useProduct } from '@magento/peregrine/lib/talons/RootComponents/Product/useProduct';",
    '// Removed existing import\n'
);

productComponent.addImport(
    "import { useProduct as useCustomProduct } from 'src/talons/ProductFullDetail/useProduct';"
);

productComponent.spliceSource({
    before: 'useProduct({',
    insert: 'useCustomProduct({',
    remove: 'useProduct({'.length
});

}

module.exports = localIntercept; `

  1. docker-compose build
  2. docker-compose up -d
  3. go to localhost:443
  4. see what local-intercept do nothing

Expected behavior

My pwa works as local-intercept.js has nothing inside I have no errors in docker logs or console of browser or something else

Possible solutions

I need more info how local-intercept.js works, maybe it depends of not clean decision what i dont find in docs

Please complete the following device information:

Please let us know what packages this bug is in regards to:

m2-assistant[bot] commented 1 month ago

Hi @abalshakou. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information. Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.

glo82145 commented 1 month ago

@adobe export issue to JIRA project PWA as Bug

github-jira-sync-bot commented 1 month ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/PWA-3355 is successfully created for this GitHub issue.