Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The (es5) import.meta warning does not take defines into account #1868

Closed
benmerckx opened this issue Dec 18, 2021 · 0 comments
Closed

The (es5) import.meta warning does not take defines into account #1868

benmerckx opened this issue Dec 18, 2021 · 0 comments

Comments

@benmerckx
Copy link

Even when pre-defining every usage of import.meta the warning is passed.

require('esbuild')
  .transform('import.meta.x', {
    target: 'es5',
    define: {'import.meta.x': '42'}
  }).then(console.log)

Results in:

{
  warnings: [
    {
      detail: undefined,
      location: [Object],
      notes: [],
      pluginName: '',
      text: '"import.meta" is not available in the configured target environment ("es5") and will be empty'
    }
  ],
  code: 'const import_meta = {};\n42;\n',
  map: ''
}
@benmerckx benmerckx changed the title The (es5) import.meta warningdoes not take defines into account The (es5) import.meta warning does not take defines into account Dec 18, 2021
@evanw evanw closed this as completed in 8187e73 Dec 20, 2021
vikunja-bot pushed a commit to go-vikunja/frontend that referenced this issue Dec 20, 2021
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [esbuild](https://github.com/evanw/esbuild) | devDependencies | patch | [`0.14.5` -> `0.14.6`](https://renovatebot.com/diffs/npm/esbuild/0.14.5/0.14.6) |

---

### Release Notes

<details>
<summary>evanw/esbuild</summary>

### [`v0.14.6`](https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#&#8203;0146)

[Compare Source](evanw/esbuild@v0.14.5...v0.14.6)

-   Fix a minifier bug with BigInt literals

    Previously expression simplification optimizations in the minifier incorrectly assumed that numeric operators always return numbers. This used to be true but has no longer been true since the introduction of BigInt literals in ES2020. Now numeric operators can return either a number or a BigInt depending on the arguments. This oversight could potentially have resulted in behavior changes. For example, this code printed `false` before being minified and `true` after being minified because esbuild shortened `===` to `==` under the false assumption that both operands were numbers:

    ```js
    var x = 0;
    console.log((x ? 2 : -1n) === -1);
    ```

    The type checking logic has been rewritten to take into account BigInt literals in this release, so this incorrect simplification is no longer applied.

-   Enable removal of certain unused template literals ([#&#8203;1853](evanw/esbuild#1853))

    This release contains improvements to the minification of unused template literals containing primitive values:

    ```js
    // Original code
    `${1}${2}${3}`;
    `${x ? 1 : 2}${y}`;

    // Old output (with --minify)
    ""+1+2+3,""+(x?1:2)+y;

    // New output (with --minify)
    x,`${y}`;
    ```

    This can arise when the template literals are nested inside of another function call that was determined to be unnecessary such as an unused call to a function marked with the `/* @&#8203;__PURE__ */` pragma.

    This release also fixes a bug with this transformation where minifying the unused expression `` `foo ${bar}` `` into `"" + bar` changed the meaning of the expression. Template string interpolation always calls `toString` while string addition may call `valueOf` instead. This unused expression is now minified to `` `${bar}` ``, which is slightly longer but which avoids the behavior change.

-   Allow `keyof`/`readonly`/`infer` in TypeScript index signatures ([#&#8203;1859](evanw/esbuild#1859))

    This release fixes a bug that prevented these keywords from being used as names in index signatures. The following TypeScript code was previously rejected, but is now accepted:

    ```ts
    interface Foo {
      [keyof: string]: number
    }
    ```

    This fix was contributed by [@&#8203;magic-akari](https://github.com/magic-akari).

-   Avoid warning about `import.meta` if it's replaced ([#&#8203;1868](evanw/esbuild#1868))

    It's possible to replace the `import.meta` expression using the `--define:` feature. Previously doing that still warned that the `import.meta` syntax was not supported when targeting ES5. With this release, there will no longer be a warning in this case.

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1218
Co-authored-by: renovate <[email protected]>
Co-committed-by: renovate <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant