zodern / melte

Svelte compiler for Meteor with built in tracker integration and HMR
MIT License
32 stars 14 forks source link

Meteor 3.0 Migrations "ReferenceError: __DYNAMIC_VERSIONS__ is not defined" #36

Open Sergeant61 opened 2 months ago

Sergeant61 commented 2 months ago

Hello @zodern, I recently migrated my project to Meteor 3.0 and encountered an issue. I found out where the problem is coming from, but what can we do as a solution?

I updated my application sequentially with the following commands:

meteor update --release 3.0-rc.2
meteor reset
rm -rf node_modules
rm -rf package-lock.json
meteor npm i

Then I ran my application.

meteor --settings settings.json --port 4100 --raw-logs

The application runs successfully, but on the client side, the application remains on a white screen and I get the following error in the log.

Uncaught ReferenceError: __DYNAMIC_VERSIONS__ is not defined
    at module (dynamic-import.js:452:16)
    at fileEvaluate (modules-runtime-hot.js:386:7)
    at Module.require (modules-runtime-hot.js:268:27)
    at mod.require (modules.js:295:33)
    at require (modules-runtime-hot.js:308:21)
    at module (dynamic-import.js:30:23)
    at fileEvaluate (modules-runtime-hot.js:386:7)
    at Module.require (modules-runtime-hot.js:268:27)
    at mod.require (modules.js:295:33)
    at Object.require (modules-runtime-hot.js:308:21)

My observation is that when I remove the svelte:compiler setting from package.json and add the static-html@1.3.3-rc300.2 package to the application, it works.

Below is the content of the packages file and package.json for the application.

packages:

meteor-base@1.5.2-rc300.2             # Packages every Meteor app needs to have
mobile-experience@1.1.2-rc300.2       # Packages for a great mobile UX
mongo@2.0.0-rc300.2                   # The database Meteor supports right now

standard-minifier-css@1.9.3-rc300.2   # CSS minifier run for production mode
standard-minifier-js@3.0.0-rc300.2    # JS minifier run for production mode
es5-shim@4.8.1-rc300.2                # ECMAScript 5 compatibility for older browsers
ecmascript@0.16.9-rc300.2             # Enable ECMAScript2015+ syntax in app code
typescript@5.4.3-rc300.2              # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.6.0-rc300.2            # Server-side component of the `meteor shell` command

# static-html@1.3.3-rc300.2             # Define static page content in .html files
zodern:melte                          # Meteor package to allow us to create files with the .svelte extension
hot-module-replacement@0.5.4-rc300.2  # Update client in development without reloading the page
zodern:types                          # Enable types from meteor/atmosphere packages

reactive-var@1.0.13-rc300.2
reactive-dict@1.3.2-rc300.2
# universe:i18n
accounts-password@3.0.0-rc300.2
accounts-2fa@3.0.0-rc300.2
random@1.2.2-rc300.2
mdg:validated-method
# percolate:migrations
email@3.0.0-rc300.2
fetch@0.1.5-rc300.2

package.json:

{
  "name": "namaz-vakti-app",
  "private": true,
  "scripts": {
    "start": "meteor --settings settings.json --port 4100 --raw-logs",
    "start:android": "meteor run android-device --settings settings.json --port 4100 --raw-logs --mobile-server=192.168.1.150",
    "deploy:prod": "mup deploy --config=.deploy/prod/mup.js --settings=.deploy/prod/settings.json --verbose",
    "stop:prod": "mup stop --config=.deploy/prod/mup.js --settings=.deploy/prod/settings.json --verbose",
    "restart:prod": "mup restart --config=.deploy/prod/mup.js --settings=.deploy/prod/settings.json",
    "reconfig:prod": "mup reconfig --config=.deploy/prod/mup.js --settings=.deploy/prod/settings.json",
    "setup:prod": "mup setup --config=.deploy/prod/mup.js --settings=.deploy/prod/settings.json --verbose",
    "ssh:prod": "mup ssh --config=.deploy/prod/mup.js --settings=.deploy/prod/settings.json",
    "logs:prod": "mup logs --tail 200 -f --config=.deploy/prod/mup.js --settings=.deploy/prod/settings.json",
    "shell:prod": "meteor mongo shell --settings=.deploy/prod/settings.json"
  },
  "dependencies": {
    "@babel/runtime": "^7.20.6",
    "@material-tailwind/html": "^2.2.2",
    "@sentry/svelte": "^7.108.0",
    "autoprefixer": "^10.4.17",
    "bcrypt": "^5.1.0",
    "classnames": "^2.5.1",
    "daisyui": "^4.7.2",
    "dayjs": "^1.11.9",
    "hex-to-css-filter": "^5.4.0",
    "meteor-node-stubs": "^1.2.5",
    "notiflix": "^3.2.6",
    "postcss": "^8.4.33",
    "postcss-load-config": "^5.0.2",
    "simpl-schema": "^3.4.1",
    "svelte": "3.54.0",
    "svelte-preprocess": "^5.1.3",
    "tailwindcss": "^3.4.1",
    "tippy.js": "^6.3.7",
    "toastify-js": "^1.12.0"
  },
  "devDependencies": {
    "@types/jquery": "^3.5.16",
    "@types/toastify-js": "^1.11.1",
    "tinro": "^0.6.12",
    "typescript": "^5.2.2"
  },
  "meteor": {
    "mainModule": {
      "client": "client/main.js"
    },
    "nodeModules": {
      "recompile": {
        "svelte": [
          "legacy"
        ]
      }
    },
    "testModule": "tests/main.js"
  },
  "svelte:compiler": {
    "extensions": [
      "svelte",
      "html"
    ],
    "hydratable": true,
    "css": false
  }
}
zodern commented 2 months ago

I'm pretty sure this would be improved by https://github.com/meteor/meteor/pull/12675. The build is erroring part way through but Meteor is silently ignoring the error and trying to run the app. I've seen this before with Meteor 3.

Sergeant61 commented 3 weeks ago

Hello, I recently tried to try meteor 3.0 again, I cannot use svelte: compiler both in my own project and in zero installation. The error is as follows.


[[[[[ ~/works/svelte-deneme-302b4 ]]]]]       

=> Started proxy.                             
=> Started HMR server.                        
=> Started MongoDB.                           
/Users/recepozen/.meteor/packages/meteor-tool/.3.0.2-beta.4.bf63lc.6u4vs++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/runners/run-app.js:380
        throw e;
        ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
    at Hash.update (node:internal/crypto/hash:115:11)
    at /Users/recepozen/.meteor/packages/meteor-tool/.3.0.2-beta.4.bf63lc.6u4vs++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/watch.ts:329:28
    at Array.forEach (<anonymous>)
    at /Users/recepozen/.meteor/packages/meteor-tool/.3.0.2-beta.4.bf63lc.6u4vs++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/watch.ts:329:8
    at CssOutputResource._get (/tools/isobuild/compiler-plugin.js:1002:19)
    at ClientTarget._emitResources (/tools/isobuild/bundler.js:1301:19)
    at /tools/isobuild/bundler.js:861:7
    at Object.enterJob (/tools/utils/buildmessage.js:387:12)
    at ClientTarget.make (/tools/isobuild/bundler.js:849:5)
    at /tools/isobuild/bundler.js:3293:7
    at /tools/isobuild/bundler.js:3452:25
    at Object.capture (/tools/utils/buildmessage.js:282:5)
    at bundle (/tools/isobuild/bundler.js:3274:18)
    at bundleApp (/tools/runners/run-app.js:584:26)
    at AppRunner._runOnce (/tools/runners/run-app.js:629:35)
    at AppRunner._runApp (/tools/runners/run-app.js:951:23) {
  code: 'ERR_INVALID_ARG_TYPE'
}```
Sergeant61 commented 2 weeks ago

I found the problem here and sent a pr for a solution. https://github.com/zodern/melte-compiler/pull/11