Comments (6)
Thank you so much for the quick response @lukeed!
Webpack can be such a pain indeed... I didn't get that snippet to work immediately but it definitely pointed me to the right direction. I fiddled around with the resolve
section and got regexparam
to work but then it started complaining about worktop/router
. Eventually I arrived at the following webpack config, which fixed it for me.
module.exports = {
target: 'webworker',
entry: './index.js',
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
],
},
}
Back to the fun stuff now. Thanks again!
from worktop.
Awesome, thank you. Now have two snippets I can refer Webpack users to π Thanks!
from worktop.
Hey, thank you :)
This is a problem with Webpack. They've gone rogue & employed their own, non-spec-compliant resolution algorithm & are happy to do so because β I guess βΒ they think they're popular enough & can just do whatever they want.
That parse
method is from regexparam
, which will resolve to regexparam/dist/index.mjs
via this line. You'll see that that file has the named parse
export. Everything is setup correctly βΒ which can be verified with any other tool that's configured correctly.
That said, you can still force Webpack to load the correct file(s) via its resolve.alias
option. Your webpack.config.js
may end up looking something like:
const path = require('path');
module.exports = {
//...
resolve: {
alias: {
regexparam: require.resolve('regexparam'),
},
},
};
Lemme know if that does the trick!
from worktop.
Ah, hah, so it's the age-old mjs
issue again. If you don't mind, can you see if webpack-modules
works here?
from worktop.
Ah, hah, so it's the age-old
mjs
issue again. If you don't mind, can you see ifwebpack-modules
works here?
This works too!
from worktop.
@lukeed When switching away from Webpack, what "type" do you recommend, and what's needed in order to migrate away from webpack?
In my wrangler.toml
file, if I remove webpack and instead write "javascript" I get an different error. The examples in this repo doesn't even have a wrangler.toml file, but if I omit it wrangler will complain:
Error: missing field `type`
If I set it to type "javascript" I get:
Uncaught SyntaxError: Cannot use import statement outside a module
For now the only solution is to default back to using webpack with a custom webpack.config.js
from worktop.
Related Issues (20)
- Using Worktop in a Pages website HOT 3
- Use Sveltekit and worktop together? HOT 2
- How to set multiple cookies? HOT 2
- Worktop Middlewares Example HOT 4
- Durable Objects example HOT 2
- The example of timing requests might be misleading HOT 1
- Using official Cloudflare types HOT 4
- Can I use Worktop with Fastly Compute@Edge? HOT 1
- Is it going to be official by cloudflare?
- Cache API and KV: Concerns/Questions/Usage HOT 1
- How to access `.env` with Wrangler 2 HOT 2
- Provide a "test" module HOT 4
- Serving HTML files HOT 6
- How to use with cron / scheduled event ? HOT 2
- Is `worktop@next` safe to use in production? HOT 2
- Add generic typing for Router.add handler
- The uploaded script has no registered event handlers. [API code: 10068] HOT 1
- Add sub-routers HOT 2
- Node 16+ ESM TypeScript error HOT 1
- `isCacheable` allowed cache by default if the `cache-control` header is empty may leading to a security flaw in ssg content HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from worktop.