aurelia / cli

The Aurelia 1 command line tool. Use the CLI to create projects, scaffold components, and bundle your app for release.
MIT License
407 stars 133 forks source link

built-in bundler cannot process .mjs third party files #1204

Closed swalters closed 1 year ago

swalters commented 1 year ago

The bundler wants to append .js to every file name. Can we get a fix so that it ignores this for .mjs extensions?

For now, I'm having to rename any .mjs files to .js to make it work.

3cp commented 1 year ago

It's in your local aurelia_project/aurelia.json field transpiler.fileExtension. Change it from ".js" to ".mjs" and try again.

3cp commented 1 year ago

BTW, with .cjs and .mjs file, it's required to use explicit import foo from "./foo.mjs";.

Implicit import foo from "./foo"; only works with the old .js for Nodejs https://nodejs.org/dist/latest-v18.x/docs/api/modules.html#all-together.

3cp commented 1 year ago

Sorry, not transpiler.fileExtension, that affects the aurelia_project/ files, not src/ files.

Update transpiler.source from "src/**/*.js" to "src/**/*.mjs".

Note you need to update all src/ files import to explicit import envirnoment from "./environment.mjs";.

One more thing, update aurelia_project/tasks/transpile.js from .pipe(rename('environment.js')) to .pipe(rename('environment.mjs')).

3cp commented 1 year ago

My bad. For 3rd party file, we will release a patch soon.

3cp commented 1 year ago

Please try aurelia-cli v3.0.2.

swalters commented 1 year ago

@3cp works great. Thanks so much for keeping Aurelia-cli up to date.