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

Bundler - Unable to bundle log FileHandler #8486

Closed
jmoalves opened this issue Nov 25, 2020 · 0 comments · Fixed by #8575
Closed

Bundler - Unable to bundle log FileHandler #8486

jmoalves opened this issue Nov 25, 2020 · 0 comments · Fixed by #8575
Labels
bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling)

Comments

@jmoalves
Copy link

When using deno log (https://deno.land/[email protected]/log) FileHandler, deno bundler produces code without FileHandler declaration.

How to reproduce

Source code

import * as log from "https://deno.land/std/log/mod.ts";

export async function myCLI(): Promise<void> {
    await log.setup({
        handlers: {
            file: new log.handlers.FileHandler("DEBUG", {
                filename: 'my.log'
            }),
            console: new log.handlers.ConsoleHandler("INFO")
        },
        loggers: {
            default: {
                level: "DEBUG",
                handlers: ["console", "file"]
            }
        }
    });

    log.info("Ok!");
}

if (import.meta.main) {
    myCLI();
}

saving it as bundleTest.ts

Working scenario - without deno bundle

C:\bundleTest>deno run --allow-write bundleTest.ts
INFO Ok!

Failure - deno bundle

C:\bundleTest>deno bundle bundleTest.ts bundleTest.js
Bundle file:///C:/bundleTest/bundleTest.ts
Check file:///C:/bundleTest/bundleTest.ts
Emit "bundleTest.js" (23.35KB)
C:\bundleTest>deno run --allow-write bundleTest.js
error: Uncaught (in promise) ReferenceError: FileHandler is not defined
            file: new FileHandler("DEBUG", {
                      ^
    at myCLI (file:///C:/bundleTest/bundleTest.js:807:23)
    at file:///C:/bundleTest/bundleTest.js:825:5

Deno version

1.5.4

Dependency info

C:\bundleTest>deno info bundleTest.ts
local: C:\bundleTest\bundleTest.ts
type: TypeScript
compiled: C:\Users\jmaur\AppData\Local\deno\gen\file\C\bundleTest\bundleTest.ts.js
deps: 9 unique (total 56.95KB)

file:///C:/bundleTest/bundleTest.ts (568B)
└─┬ https://deno.land/std/log/mod.ts (5.66KB)
  ├── https://deno.land/[email protected]/_util/assert.ts *
  ├─┬ https://deno.land/[email protected]/log/handlers.ts (6.16KB)
  │ ├── https://deno.land/[email protected]/fmt/colors.ts (11.27KB)
  │ ├── https://deno.land/[email protected]/fs/exists.ts (708B)
  │ ├─┬ https://deno.land/[email protected]/io/bufio.ts (21.18KB)
  │ │ ├── https://deno.land/[email protected]/_util/assert.ts (405B)
  │ │ └── https://deno.land/[email protected]/bytes/mod.ts (4.34KB)
  │ └── https://deno.land/[email protected]/log/levels.ts (1.54KB)
  ├── https://deno.land/[email protected]/log/levels.ts *
  └─┬ https://deno.land/[email protected]/log/logger.ts (5.15KB)
    └── https://deno.land/[email protected]/log/levels.ts *
@lucacasonato lucacasonato added cli related to cli/ dir swc related to swc (bundling/transpiling) upstream Changes in upstream are required to solve these issues bug Something isn't working correctly and removed upstream Changes in upstream are required to solve these issues labels Nov 26, 2020
kdy1 added a commit to kdy1/swc that referenced this issue Nov 27, 2020
kdy1 added a commit to kdy1/swc that referenced this issue Nov 27, 2020
@kdy1 kdy1 mentioned this issue Nov 27, 2020
3 tasks
kdy1 added a commit to swc-project/swc that referenced this issue Nov 27, 2020
swc_bundler:
 - Handle dependencies of circular modules in wrapped modules. (#1214)
 - Handle `export * from './file.ts'` properly. (denoland/deno#8481)
 - Fix deglobbing. (denoland/deno#8486)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants