Dfx 0.11.0 is promoted with breaking changes

Release notes: Release Notes | Internet Computer Home

Breaking changes

Duplicate asset keys are now reported as errors

The webpack.config.js included in new projects created by previous versions of dfx copied all files from src/<project>/assets into dist/<project>. Since the default asset canister defines both of these as a source, these assets will show up as duplicates.

For existing projects, you will need to remove the following from webpack.config.js and delete the dist/ directory, or else dfx deploy will fail:

    new CopyPlugin({
      patterns: [
        {
          from: path.join(__dirname, "src", frontendDirectory, "assets"),
          to: path.join(__dirname, "dist", frontendDirectory),
        },
      ],
    }),

Removed deprecated candid path environment variable

Any reference to environment variables of the form CANISTER_CANDID_{name} (formerly used in Rust projects) must be replace with CANISTER_CANDID_PATH_{name}.

6 Likes

Another breaking change: if you have a custom canister type that uses a prebuilt .wasm file, you might not have a build field. If this is the case, you’ll see an error like this:

Error: Failed to read config from current working directory.
Caused by: Failed to read config from current working directory.
    Failed to read config from directory /Users/me/dev/dfinity/examples/rust/basic_bitcoin.
Failed to load config from /Users/me/dev/dfinity/examples/rust/basic_bitcoin/dfx.json.
  missing field `build` at line 17 column 5

dfx 0.11.1 will make the build field optional again. In the meantime you can add "build": [] to your canister definition.

6 Likes

Is it planned to make gzipped binaries compatible with dfx deploy? dfx deploy with gzip · Issue #2357 · dfinity/sdk · GitHub

2 Likes

I think this is a very reasonable feature. I added it to our backlog.

3 Likes

Hey !

I’m having an issue related to the GZip feature as well when I try to deploy with this version. Is this related to your issue @lastmjs ?

Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build call canisters.
    Failed while trying to build all canisters.
      The build step failed for canister 'rrkah-fqaaa-aaaaa-aaaaq-cai' (main) with an embedded error: Failed to build custom canister main.: Failed to add candid service metadata from [..]/main/src/main.did to [..]/target/wasm32-unknown-unknown/release/main.wasm.gz.: 
Failed to parse file [...]/target/wasm32-unknown-unknown/release/main.wasm.gz: Bad magic number (at offset 0)

FYI : I have a custom build field setup in dfx.json for my canister.

You can’t put the .gz path into your dfx.json, you have to keep that as just a .wasm path. You need to separately install the .gz binary without the use of dfx deploy: Large web assembly modules | Internet Computer Home

Oh :open_mouth:
That’s a bummer, It used to work with dfx 0.10.1 using the deploy command :confused:
Well I guess I’ll stick with 0.10.1 until it’s fixed then :slight_smile:

Thanks for the answer @lastmjs

1 Like

This works for me. I dont know why 0.11.1 does not work. Any other suggestion how to immigrate 0.10.0 to 0.11.1?

What issue are you experiencing exactly?

Now when we do npm start the files aren’t in dist.

That sounds like a webpack config issue. Personally, I don’t usually expect npm start to have side effects with dist - that’s generally reserved for npm build.

If you need that, though, you can either use the copy-webpack-plugin to copy assets into dist (may slow down startup).

Additionally, if the issue is that the assets are not available in dist during dfx deploy, you can either use the copy plugin, or you can point dfx at your asset directories by listing them in the source list

I use the default webpack that came with dfx start though,
it’s the rule

rules: [
     { test: /\.(ts|tsx|jsx)$/, loader: "ts-loader" },
     { test: /\.css$/, use: ['style-loader','css-loader'] }
  ]
Refused to apply style from 'http://localhost:8080/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
log.js:24 [HMR] Waiting for update signal from WDS...
react-dom.development.js:29742 Download the React DevTools for a better development experience: https://reactjs.org/link/react-devtools
bootstrap:27 Uncaught DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet': Cannot access rules
    at n (http://localhost:8080/index.js:112315:13711)
    at F (http://localhost:8080/index.js:112315:15860)
    at http://localhost:8080/index.js:112315:16468
    at http://localhost:8080/index.js:112315:2588
    at http://localhost:8080/index.js:112315:16092
    at K (http://localhost:8080/index.js:112315:16720)
    at Q (http://localhost:8080/index.js:112315:17176)
    at ne (http://localhost:8080/index.js:112315:17275)
    at ./node_modules/@psychedelic/plug-connect/dist/plug-connect.esm.js (http://localhost:8080/index.js:18997:82)
    at __webpack_require__ (http://localhost:8080/index.js:112345:33)
index.js:551 [webpack-dev-server] Hot Module Replacement enabled.
index.js:551 [webpack-dev-server] Live Reloading enabled.
:8080/favicon.ico:1          Failed to load resource: the server responded with a status of 404 (Not Found)
localhost/:1 Refused to apply style from 'http://localhost:8080/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
DevTools failed to load source map: Could not load content for chrome-extension://gighmmpiobklfepjocnamgkkbiglidom/browser-polyfill.js.map: System error: net::ERR_FILE_NOT_FOUND

it’s because it’s not found

npm start for the 0.11.0 new template is busted. You can use the CopyPlugin config from the top of this thread, or you can use the 0.11.0 new project