Create Sourcemaps with Vue3 in babel.config.js? - babeljs

I'm using Vue3. I want generate sourcemaps using Babel and then get the relative path.
Here is my folder structure for the frontend dir:
├── CONTRIBUTING.MD
├── Changelog.js
├── README.md
├── babel.config.js
├── config
├── dist
├── node_modules
├── package-lock.json
├── package.json
├── postcss.config.js
├── public
├── sample.env
├── src
├── tailwind.config.js
├── tests
└── unit-test
I'm working on integrating Sentry with the Vue3 frontend of a project. The last step is creating and uploading source maps to Sentry.
Here is my Babel config file:
module.exports = {
presets: [
'#vue/cli-plugin-babel/preset'
], // I tried this but this doesn't seem to work.
sourceMaps: true
}
Here is the package.json:
{
"name": "project",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"ci:lint": "vue-cli-service lint --no-fix --max-warnings=0",
"prepare": "cd .. && husky install .husky",
"sb:build": "vue-cli-service storybook:build -c config/storybook",
"sb:serve": "vue-cli-service storybook:serve -p 6006 -c config/storybook"
},
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^6.1.1",
"#fortawesome/free-regular-svg-icons": "^6.1.1",
"#fortawesome/free-solid-svg-icons": "^6.1.1",
"#fortawesome/vue-fontawesome": "^3.0.0-5",
"#fullstory/browser": "^1.6.0",
"#gtm-support/vue-gtm": "^1.6.0",
"#sentry/fullstory": "^1.1.8",
"#sentry/tracing": "^6.19.7",
"#sentry/vue": "^6.19.7",
"#tailwindcss/postcss7-compat": "^2.0.2",
"autoprefixer": "^9",
"aws-amplify": "^4.3.22",
"aws-appsync": "^4.1.7",
"axios": "^0.27.2",
"core-js": "^3.23.0",
"d3": "^7.5.0",
"dayjs": "^1.11.3",
"graphql-tag": "^2.12.6",
"html-to-pdfmake": "^2.4.4",
"pdfmake": "^0.2.5",
"postcss": "^8.4.14",
"register-service-worker": "^1.7.1",
"tailwindcss": "npm:#tailwindcss/postcss7-compat#^2.0.2",
"uuid": "^8.3.2",
"vue": "^3.2.28",
"vue-router": "^4.0.16",
"vue-toastification": "^2.0.0-rc.5",
"vue3-country-region-select": "^1.0.0",
"vue3-draggable-resizable": "1.6.4",
"vue3-markdown-it": "^1.0.10",
"vuex": "^4.0.0-0"
},
"devDependencies": {
"#storybook/addon-essentials": "^6.0.26",
"#storybook/addon-links": "^6.0.26",
"#storybook/vue3": "^6.0.26",
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-plugin-pwa": "~4.5.0",
"#vue/cli-plugin-router": "~4.5.0",
"#vue/cli-plugin-vuex": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0",
"#vue/eslint-config-standard": "^5.1.2",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^7.0.0",
"husky": "^7.0.4",
"sass": "^1.51.0",
"sass-loader": "^10.2.1",
"vue-cli-plugin-storybook": "~2.1.0",
"vue-cli-plugin-tailwind": "^3.0.0-beta.0"
}
}

Related

#sveltejs/adapter-cloudflare. I get many error while run `npm run build`

I'm Using #sveltejs/adapter-cloudflare to deploy my project to Cloudflare Pages.
I'm tried to use this package for a simple sveletKit app. It can success deploy to Pages.
But with more complex project, I got many many ERROR log while run build.
This is the log: https://pastebin.com/Yhw1Gu0c
And this is my package.json
"name": "app",
"version": "0.0.1",
"scripts": {
"dev": "vite dev --port 3331",
"build": "vite build",
"package": "svelte-kit package",
"preview": "vite preview",
"test": "playwright test",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
"format": "prettier --write --plugin-search-dir=. ."
},
"devDependencies": {
"#carbon/colors": "^11.3.0",
"#firebase/app-types": "^0.7.0",
"#playwright/test": "^1.22.2",
"#solana/qr-code-styling": "1.6.0-beta.0",
"#sveltejs/adapter-auto": "next",
"#sveltejs/adapter-cloudflare": "^1.0.0-next.31",
"#sveltejs/kit": "next",
"#typescript-eslint/eslint-plugin": "^5.27.0",
"#typescript-eslint/parser": "^5.27.0",
"bignumber.js": "^9.0.2",
"carbon-components-svelte": "^0.67.4",
"carbon-icons-svelte": "^11.2.0",
"carbon-preprocess-svelte": "^0.9.1",
"cookie": "^0.5.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-svelte3": "^4.0.0",
"firebase-admin": "^11.0.1",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
"sass": "^1.54.0",
"svelte": "^3.44.0",
"svelte-check": "^2.7.1",
"svelte-preprocess": "^4.10.6",
"tslib": "^2.3.1",
"typescript": "^4.7.4",
"vite": "^3.0.0"
},
"type": "module",
"dependencies": {
"#solana/web3.js": "^1.50.1",
"firebase": "^9.9.1"
}
}

'import' and 'export' may appear only with 'sourceType: module when import "#solana/web3.js"

I am going to use solanaweb3 on babelrc project.
When I run npm start I am getting .
I have gone through many posts on github and stackoverflow.
npm install -g browserify
npm install --save-dev browserify babelify babel-preset-es2015 babel-preset-stage-0 babel-preset-env babel-preset-react
npm install #babel/core --save
What is solution?
Here is my package.json content.
"scripts": {
"start": "budo src/index.js"
},
"dependencies": {
"#babel/runtime": "^7.14.8",
"#solana/web3.js": "^1.29.2",
"babel-core": "7.0.0-bridge.0"
},
"devDependencies": {
"#babel/core": "^7.15.5",
"#babel/plugin-transform-runtime": "^7.15.0",
"#babel/preset-env": "^7.15.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babelify": "^10.0.0",
"browserify": "^16.5.2",
"budo": "^11.6.4"
},
"browserify": {
"transform": [
[
"babelify",
{
"presets": [
"#babel/preset-env"
]
}
]
]
}
}

how to remove or disable ionic 5 default splash screen ionic version 5

How can I replace Ionic 5 default splash screen with a custom HTML or Lottie one?
default spash screen
My package.json is
{
"name": "safenotes",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "~10.0.0",
"#angular/core": "~10.0.0",
"#angular/fire": "^6.1.1",
"#angular/forms": "~10.0.0",
"#angular/platform-browser": "~10.0.0",
"#angular/platform-browser-dynamic": "~10.0.0",
"#angular/router": "~10.0.0",
"#capacitor/android": "^2.4.3",
"#capacitor/core": "2.4.3",
"#ionic-native/core": "^5.0.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^5.0.0",
"#ionic/storage": "^2.3.1",
"firebase": "^8.1.1",
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.1000.0",
"#angular/cli": "~10.0.5",
"#angular/compiler": "~10.0.0",
"#angular/compiler-cli": "~10.0.0",
"#angular/language-service": "~10.0.0",
"#capacitor/cli": "2.4.3",
"#ionic/angular-toolkit": "^2.3.0",
"#types/jasmine": "~3.5.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~3.3.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.9.5"
},
"description": "An Ionic project"
}
Unfortunately it looks like only png files are supported at the moment.
You need to use Capacitor Assets (formerly known as cordova-res).
Install it globally:
$ npm install -g cordova-res
Than prepare the following files in the resources folder:
resources/
├── android
| ├── icon-background.png (1)
| └── icon-foreground.png (1)
├── icon.png
└── splash.png
config.xml (2)
Then generate all the required icons and splash screens with:
$ cordova-res
You can also use the --copyoption to automatically copy the files into the android/ios projects, e.g.:
$ cordova-res ios --skip-config --copy
$ cordova-res android --skip-config --copy
(1) These icons are only necessary if you want adaptive icons for android to be generated. They must be present if your android project already uses default adaptive icons from capacitor.
(2) Config file is optional as well, check the docs for updated instructions and many more details.

babel v7 upgrade causing unexpected token import in files imported by related path and in plugin-transform-runtime

After upgrading to 7 none of the googled answers not working.
I have a project structure
package.json
"scripts": {
"start": "yarn dev:start",
"restart": "touch src/shared/app.jsx",
"dev:start": "cross-env BABEL_ENV=dev nodemon -e js,jsx --watch src/server --exec babel-node src/server",
"dev:wds": "cross-env BABEL_ENV=dev webpack-dev-server --progress --info-verbosity verbose",
"prod:build": "rimraf lib dist && babel src -d lib --ignore .test.js && cross-env NODE_ENV=production webpack -p --progress --color --display-error-details",
"prod:start": "cross-env NODE_ENV=production pm2 start lib/server && pm2 logs",
"prod:stop": "pm2 delete server",
"lint": "eslint src webpack.config.babel.js --ext .js,.jsx",
"test": "yarn lint && flow && jest --coverage",
"precommit": "yarn test",
"prepush": "yarn test && yarn prod:build"
},
"devDependencies": {
"#babel/cli": "^7.8.4",
"#babel/core": "^7.0.0",
"#babel/node": "^7.0.0",
"#babel/plugin-proposal-class-properties": "^7.0.0",
"#babel/plugin-proposal-json-strings": "^7.0.0",
"#babel/plugin-syntax-dynamic-import": "^7.8.3",
"#babel/plugin-syntax-import-meta": "^7.0.0",
"#babel/plugin-transform-modules-commonjs": "^7.8.3",
"#babel/plugin-transform-runtime": "^7.8.3",
"#babel/preset-env": "^7.0.0",
"#babel/preset-flow": "^7.0.0",
"#babel/preset-react": "^7.0.0",
"#babel/register": "^7.8.3",
"#gfx/zopfli": "^1.0.10",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.4.2",
"babel-loader": "^8.0.0",
"babel-plugin-flow-react-proptypes": "^4.1.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-recharts": "^1.2.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.14",
"babel-plugin-webpack-alias": "^2.1.2",
"compression-webpack-plugin": "^2.0.0",
"cross-env": "^5.2.0",
"css-loader": "^0.28.5",
"html-webpack-plugin": "^3.2.0",
"isomorphic-style-loader": "^4.0.0",
"jest": "^20.0.4",
"lodash-webpack-plugin": "^0.11.5",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"url-loader": "^0.5.9",
"webpack": "^4.22.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.10.3"
},
"dependencies": {
"#babel/core": "^7.0.0",
"#babel/plugin-proposal-object-rest-spread": "^7.0.0",
"#babel/runtime": "^7.3.4",
"#babel/runtime-corejs3": "^7.4.3",
"babel-plugin-transform-imports": "^1.5.0",
"core-js": "^3.6.4",
"webpack-spritesmith": "^0.4.1"
}
babel.config.json
{
"presets": [
[
"#babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": {
"version": 3,
"proposals": true
},
"debug": true
}
],
"#babel/preset-flow",
"#babel/preset-react"
],
"plugins": [
"lodash",
"flow-react-proptypes",
"#babel/plugin-proposal-object-rest-spread",
"#babel/plugin-proposal-class-properties",
[
"transform-imports",
{
"react-router": {
"transform": "react-router/${member}",
"preventFullImport": true
}
}
],
[
"#babel/plugin-transform-runtime",
{
"corejs": 3,
"helpers": true,
"useESModules": true
}
]
]
}
First babel doesn't transpile plugin-transform-runtime (or perhaps any file in node_modules)
After babel-node src/server
Got an error Unexpeted token import
Second If i turn off plugin-transform-runtime, everything is fine, until babel meet a
relative imported file and import in it
Every others import constructions don't lead to such errors
imported file causing error importing in it
Error just here
Whatever packages i've been installed, whatever config files neither .babelrc nor babel.config.json - not working, in babel 6 have no problems
Is it rooting or structure issues, or maybe config?
Tried to re-install all packages, clearing cache. Same error
However, prod:build aka babel src -d lib is working fine, but webpack then crushed on same
\node_modules\#babel\runtime-corejs3\helpers\esm\defineProperty.js:1
(function (exports, require, module, __filename, __dirname) { import _Object$defineProperty from "../../core-js/object/define-property";
^^^^^^
SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at NativeCompileCache._moduleCompile (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\v8-compile-cache\v8-compile-cache.js:226:18)
at Module._compile (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\v8-compile-cache\v8-compile-cache.js:172:36)
at Module._compile (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\pirates\lib\index.js:99:24)
at Module._extensions..js (module.js:660:10)
at Object.newLoader [as .js] (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\pirates\lib\index.js:104:7)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\Users\marat.m\PhpstormProjects\b2b-node\webpack.config.babel.js:29:47)
at Module._compile (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
at Module._compile (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\pirates\lib\index.js:99:24)
at Module._extensions..js (module.js:660:10)
at Object.newLoader [as .js] (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\pirates\lib\index.js:104:7)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at WEBPACK_OPTIONS (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\bin\convert-argv.js:133:13)
at requireConfig (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\bin\convert-argv.js:135:6)
at C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\bin\convert-argv.js:142:17
at Array.forEach (<anonymous>)
at module.exports (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\bin\convert-argv.js:140:15)
at yargs.parse (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\bin\cli.js:241:39)
at Object.parse (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\node_modules\yargs\yargs.js:563:18)
at C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\bin\cli.js:219:8
at Object.<anonymous> (C:\Users\marat.m\PhpstormProjects\b2b-node\node_modules\webpack-cli\bin\cli.js:538:3)

dotenv not working after transcompile with Babel

I have code reading .env using dotenv that is working in dev but after transcompiling with Babel the values from process.env are undefined. I created a sample program to illustrate the problem which is below.
If I'm in projectRoot and run
npm run start-w
then
console.log(process.env.VAR1)
prints the value 'var1Val'
However, if I do
npm run build
cd dist
node index.js
the value of VAR1 is 'undefined'.
index.js
import 'dotenv/config'
console.log('VAR1', process.env.VAR1)
.env
VAR1=var1val
VAR2=var2val
VAR3=var3val
.babelrc
{
"presets": ["#babel/preset-env"],
"plugins": [
"#babel/plugin-transform-runtime",
]
}
package.json
{
"name": "dotenv.node-babel",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"#babel/runtime": "^7.4.3",
"dotenv": "^7.0.0"
},
"devDependencies": {
"#babel/cli": "^7.4.3",
"#babel/core": "^7.4.3",
"#babel/node": "^7.2.2",
"#babel/plugin-transform-runtime": "^7.4.3",
"#babel/preset-env": "^7.4.3",
"#types/dotenv": "^6.1.1",
"nodemon": "^1.18.11",
"rimraf": "^2.6.3"
},
"scripts": {
"clean-dist": "rimraf dist",
"build": "npm run-script clean-dist && babel . -d dist --ignore node_modules",
"start": "babel-node index.js",
"start-w": "NODE_ENV=devLocal nodemon --exec babel-node index.js"
},
"author": "",
"license": "ISC"
}
If you do not have a .env file in your build directory, try creating one. I guess that's why the environment variable is undefined.