aMarCruz / pugjs-brunch

Adds Pug (aka Jade) support to brunch.
MIT License
8 stars 3 forks source link

Uncaught TypeError: Cannot set property 'pug' of undefined at pug_runtime.js:262 #8

Closed almereyda closed 6 years ago

almereyda commented 6 years ago

When building a page with brunch and using the plugins standard configuration, with no pug key in in the plugins section of brunch_config.js, the browser console features an error about

Uncaught TypeError: Cannot set property 'pug' of undefined
at pug_runtime.js:262

The code of the site lives in

the output is commited to

and deployed to

We are currently not using pug runtime templates, and only compile one index.pug into HTML, but still wonder about this a little.

aMarCruz commented 6 years ago

@almereyda , thanks for your report. I'm busy now, but next week I'll working on trhis issue.

vladh commented 6 years ago

Also having this issue. Fixed for now by setting the plugin options to {pugRuntime: false}.

aMarCruz commented 6 years ago

@almereyda , @vladh , I could not reproduce the issue. This is the brunch-config.js of my last project:

const values = require('./app/values')

module.exports = {
  files: {
    javascripts: {
      joinTo: 'js/app.js',
      order: {
        before: [
          'vendor/screenfull.js',
          'vendor/A_remark/core.js',
          'vendor/colors.js'
        ]
      }
    },
    stylesheets: {
      joinTo: 'css/app.css'
    },
    templates: {
      joinTo: 'js/app.js'
    }
  },
  plugins: {
    jscc: {
      values: values,
      pattern: /\.(jsx?|pug)$/,
      sourceMap: true,
      sourceMapFor: /\.(jsx?|pug)$/
    },
    buble: {
      target: { chrome: 48, firefox: 48, edge: 13 },
      objectAssign: 'assign',
      jsx: 'h'
    },
    pug: {
    },
    eslint: {
      warnOnly: true
    },
    cleancss: {
      compatibility: 'ie11'
    },
    uglify: {
      ecma: 6,
    }
  },
  // Sobrescribe configuración de modo "production"
  overrides: {
    production: {
      plugins: {
        autoReload: { enabled: false },
        eslint: { warnOnly: false },
      }
    },
  },
  // custom server port
  server: {
    run: true,
    port: 8080
  },
  watcher: {
    usePolling: true
  },
}

and dependencies in package.json:

  "dependencies": {
    "dio.js": "^7.1.0",
    "easyrouter": "^1.0.0",
    "js-cookie": "^2.2.0",
    "json-brunch": "^1.5.4",
    "marked": "^0.3.6",
    "popper.js": "^1.12.8",
    "pusher-js": "^4.2.1",
    "scroll-into-view": "^1.9.1",
    "store2": "^2.5.9"
  },
  "devDependencies": {
    "auto-reload-brunch": "^2.7.1",
    "jscc-brunch": "^2.8.2",
    "brunch": "^2.10.12",
    "bublejs-brunch": "^2.10.1",
    "less-brunch": "^2.10.0",
    "clean-css-brunch": "^2.10.0",
    "eslint-brunch": "^3.12.0",
    "javascript-brunch": "^2.10.0",
    "pugjs-brunch": "^2.10.1",
    "uglify-es-brunch": "aMarCruz/uglify-es-brunch"
  },

working in ... Linux Mint 18.03 node v8.7.0 npm v5.6.0

...anyway, I published a new version with a minor change, hoping that it solves the problem. Thanks for your feedback.

vladh commented 6 years ago

@aMarCruz Just wanted to confirm that I am still having this issue, this time phrased the following way:

ReferenceError: global is not defined pug_runtime.js:261:35

Resorting to the same {pugRuntime: false} solution.

aMarCruz commented 6 years ago

@vladh thanks. I will fix this issue ASAP.

Do you know if you are using AMD or CommonJS ?