-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get the following error when trying to load built assets... #1
Comments
@asolopovas Have you tried putting import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
import rollupJson from '@rollup/plugin-json';
import rollupSvg from 'rollup-plugin-svg-import';
import wpResolve from 'rollup-plugin-wp-resolve';
const globals = {}; // add extra globals here
const plugins = [
wpResolve(),
nodeResolve( { // resolve node_modules
browser: true,
} ),
rollupJson(), // convert json files to es-modules
rollupSvg( { // import svg into bundles
stringify: true
} ),
babel( {
babelHelpers: 'bundled',
exclude: 'node_modules/**',
presets: [
[
"@babel/preset-env",
{
"modules": false,
},
],
[
'@babel/preset-react',
{
pragma: 'wp.element.createElement',
pragmaFrag: 'wp.element.Fragment',
}
],
],
} ),
commonjs( { // convert common/requirejs to esmodules
exclude: [
'src/**'
]
} ),
];
export default [
{
input: 'src/index.js',
external: Object.keys( globals ),
plugins,
output: [
{
file: 'dist/index.js',
format: 'iife',
globals,
name: 'exportName',
plugins: [ terser() ],
sourcemap: true,
}
],
},
]; It could also be a conflict with some of your other plugins but try moving it up in your plugin order and see if that helps. |
Is it possible that This is compiled file imports: import {createBlock as y, store as Q, createBlocksFromInnerBlocksTemplate as M, registerBlockType as T} from "@wordpress/blocks";
import {__ as u, sprintf as Y} from "@wordpress/i18n";
import {mapValues as ee, merge as te, sumBy as ne, times as S, dropRight as oe, get as P} from "lodash";
import {PanelBody as W, RangeControl as le, Notice as ce, ToggleControl as se, SVG as f, Path as k, __experimentalUseCustomUnits as ie, __experimentalUnitControl as re} from "@wordpress/components";
import {store as h, useBlockProps as B, useInnerBlocksProps as x, BlockControls as D, BlockVerticalAlignmentToolbar as O, InspectorControls as F, __experimentalBlockVariationPicker as ae, useSetting as ue, InnerBlocks as me} from "@wordpress/block-editor";
import {withDispatch as de, useSelect as E, useDispatch as L} from "@wordpress/data";
import {createElement as C} from "@wordpress/element";
import {SVG as Z, Path as q} from "@wordpress/primitives"; |
That line is what the plugin is supposed to handle. I've never used vite js, but I'll try setting it up there and see if something is off. |
@asolopovas it looks like vite plugins do not call the outputOptions hook of rollup which this wp-resolve uses: https://vitejs.dev/guide/api-plugin.html#universal-hooks The plugin would need to be adapted to support vite. |
If you're interested, this is how I adapted this plugin to be Vite compatible: vitejs/vite#9411. I'd love if this plugin supported it by default, instead of having to maintain a fork. I can send a PR, if you're interested. |
Hi,
I am getting the followign error when loading @wordpress/blocks do you know why that might be happning?
Here is my config:
blocks.js:
The text was updated successfully, but these errors were encountered: