Skip to content

ReferenceError: publicodes__WEBPACK_IMPORTED_MODULE_2__ is not defined #28

@martinratinaud

Description

@martinratinaud

I saw you were taking over the @koale/useworker project and thanks for that. I, anyway, have a problem you said would be fixed with your version

Here is a page to reproduce this in a nextjs 13 environment (pages router)

import rules from '@betagouv/france-chaleur-urbaine-publicodes';
import Engine from 'publicodes';
import { useWorkerFunc } from 'use-react-workers';

const createEngine = () => {
  return new Engine(rules);
};

const SimulateurPage = () => {
  // const engine = useSimulatorEngine();
  const [sortWorker, { status }] = useWorkerFunc(createEngine);

  const runCreateEngine = async () => {
    const result = await sortWorker(); // non-blocking UI
    console.log(result);
  };

  return (
    <>
      <button type="button" onClick={runCreateEngine}>
        Run Sort
      </button>
      {status}
    </>
  );
};

export default SimulateurPage;

Thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions