Giter Club home page Giter Club logo

preact-cli-plugin-async's Introduction

preact-cli-plugin-async

npm travis greenkeeper

Preact CLI plugin that adds optimized support for async/await via fast-async.

Note: this is now just a copy of preact-cli-plugin-fast-async by @plusCubed.

Why do I want this?

ormally, transpiling async/await produces a large amount of code and depends on a runtime like regenerator-runtime. While that is optimal from a compatibility standpoint, it's not so great for bundle size. Using fast-async, this plugin transforms your async functions into Promises just like you would write by hand!

It transforms this:

async () => await (await fetch('/')).text()

... to something that roughly looks like this:

function () {
	return Promise.resolve().then(function() {
		return fetch("/")
	}).then(function(e) {
		return e.text()
	})
}

Pretty great, right?

Installation

npm i -D preact-cli-plugin-async

... then include it in your project by creating a preact.config.js:

import asyncPlugin from 'preact-cli-plugin-async';

export default (config) => {
    asyncPlugin(config);
}

License

MIT
Original version Β© developit
Current fast-async version Β© Daniel Ciao

preact-cli-plugin-async's People

Contributors

developit avatar greenkeeper[bot] avatar lukeed avatar pluscubed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

preact-cli-plugin-async's Issues

TypeError: Cannot read property 'push' of undefined

preact.config.js:

import asyncPlugin from 'preact-cli-plugin-async';

export default (config, env, helpers) => {
  asyncPlugin(config);
};

error:

 npm run build                            
> [email protected] build /media/sdb1/dev/preact/test-widget
> preact build --no-prerender --clean --template src/index.ejs --service-worker false

Error: Error at /media/sdb1/dev/preact/test-widget/preact.config.js: 
TypeError: Cannot read property 'push' of undefined

An in-range update of microbundle is breaking the build 🚨

Version 0.3.1 of microbundle was just published.

Branch Build failing 🚨
Dependency microbundle
Current Version 0.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

microbundle is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes 0.3.1
  • Detect when default & named exports are used in duplicate (eg: preact) and only export a single object.
Commits

The new version differs by 3 commits.

  • 932acd6 0.3.1
  • d10fb70 second demo
  • 8960114 If defaults + named exports are detected, only export default and prune named. Enable pure properties for tree-shaking (since they're already enabled for uglify)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

Version 4.16.0 of eslint was just published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.15.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796) (Michael Ficarra)
  • af043eb Update: Add NewExpression support to comma-style (#9591) (Frazer McLean)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813) (Matija MarohniΔ‡)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852) (Kevin Partington)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855) (PiIsFour)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847) (Kevin Partington)
  • 978574f Docs: Fix examples for no-useless-escape (#9853) (Toru Kobayashi)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815) (Kevin Partington)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816) (Kevin Partington)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831) (Teddy Katz)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820) (Teddy Katz)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819) (Teddy Katz)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818) (Teddy Katz)
  • 6a5cd32 Fix: prefer-destructuring error with computed properties (fixes #9784) (#9817) (Teddy Katz)
  • 601f851 Docs: Minor modification to code comments for clarity (#9821) (rgovind92)
  • b9da067 Docs: fix misleading info about RuleTester column numbers (#9830) (Teddy Katz)
  • 2cf4522 Update: Rename and deprecate object-property-newline option (#9570) (Jonathan Pool)
  • acde640 Docs: Add ES 2018 to Configuring ESLint (#9829) (Kai Cataldo)
  • ccfce15 Docs: Minor tweaks to working with rules page (#9824) (Kevin Partington)
  • 54b329a Docs: fix substitution of {{ name }} (#9822) (Andres Kalle)
Commits

The new version differs by 22 commits.

  • 33ca1ea 4.16.0
  • 1a9ddee Build: changelog update for 4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796)
  • af043eb Update: Add NewExpression support to comma-style (#9591)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847)
  • 978574f Docs: Fix examples for no-useless-escape (#9853)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818)

There are 22 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of preact-cli is breaking the build 🚨

Version 2.1.1 of preact-cli was just published.

Branch Build failing 🚨
Dependency preact-cli
Current Version 2.1.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

preact-cli is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 16 commits.

  • ea478fa 2.1.1
  • bc0c665 remove webpack-chunk-hash plugin; (#460)
  • a911891 Merge pull request #450 from developit/pr-template
  • 37fc0d0 Add CLI version, browsers to issue_template
  • 66d138b remove documentation link
  • 3dd11b3 Adds a Pull Request tempalte for CLI
  • 9eb4622 Replace Babel Stage-1 Preset with Plugins (#444)
  • 9a7ddde Remove duplication warning (#440)
  • 193a7d5 Merge pull request #414 from developit/fix-tests
  • 5262826 Merge branch 'fix-tests' of github.com:developit/preact-cli into fix-tests
  • ba8cd16 ensure β€”name value always present in tests!
  • 7833af5 avoid exit via mkdir node_modules within builds
  • eceb0da formatting only
  • 353bd23 allow any/all prerender key values (#430)
  • aea72a9 avoid exit via mkdir node_modules within builds

There are 16 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Unexpected token: name (...) from UglifyJs

When installing this plugin on a preact-cli with default template all builds fail with the same errors. tested on several setups.

βœ– ERROR route-profile.chunk.ed753.js from UglifyJs
Unexpected token: name (Profile) [./routes/profile/index.js:4,21][route-profile.chunk.ed753.js:17,4]
βœ– ERROR route-home.chunk.e69f2.js from UglifyJs
Unexpected token: name (Home) [./routes/home/index.js:7,21][route-home.chunk.e69f2.js:36,4]
βœ– ERROR bundle.090e2.js from UglifyJs
Unexpected token: name (done) [../node_modules/preact-cli/lib/components/async.js:8,6][bundle.090e2.js:555,6]
Build failed!

Seems to be broken with latest preact-cli (3.0.0-rc6)

preact build output:

βœ– ERROR Error: TypeError: Cannot read property 'filter' of undefined

at ode_modules/preact-cli-plugin-async/dist/async-plugin.js:1:51

Which corresponds to this:

module.exports=function(e){var r=e.module.loaders.filter

Could be the change from webpack 3 to 4.

Uncaught SyntaxError: The URL '/sockjs-node' is invalid

Hey Jason,
first of all thx for this.
I'm experimenting with animateplus.js wich relies on async/await.
That's another thing ;-)

I tried to install the plugin in a new folder
preact create simple

went through including installing deps

I added the plugin as described:
npm i -D preact-cli-plugin-async

package.json

"devDependencies": {
  ...,
  "preact-cli-plugin-async": "^1.0.0"
},

I created and edited a 'preact.config.js' as described:

import asyncPlugin from 'preact-cli-plugin-async'

export default config => {
  asyncPlugin(config)
}

starting in dev-mode:
npm run dev

everything seems fine first:

Compiled successfully!
...

But opening http://localhost:8080 in browser[chrome]
logs:

sockjs.js?83d2:678 Uncaught SyntaxError: The URL '/sockjs-node' is invalid

...
  // Step 1 of WS spec - parse and validate the url. Issue #8
  var parsedUrl = new URL(url);
  if (!parsedUrl.host || !parsedUrl.protocol) {
    throw new SyntaxError("The URL '" + url + "' is invalid");    <-------- this throws X
  } else if (parsedUrl.hash) {
    throw new SyntaxError('The URL must not contain a fragment');
...

running without preact.config.js works
Unfortunately I have no idea what to do to fix?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.